The <input> element supports many attributes that control its behavior and improve the user experience. These attributes let you restrict, customize, or prefill the fields.
The 'name' attribute specifies the key under which the field's value will be submitted. The backend also uses this name to access the data.
The 'value' attribute pre-fills the field with a default value. If omitted, the field starts empty.
The 'placeholder' displays helper text inside the field until the user starts typing. It's a visual guide, not a real value.
The 'required' attribute marks the field as mandatory. The browser won’t allow the form to be submitted unless the field is filled.
With 'readonly', the field’s value can’t be modified by the user, but it will still be submitted with the form.
Fields with the 'disabled' attribute are completely inactive. They can’t be interacted with and are not included in the form submission.
The 'maxlength' attribute limits how many characters can be entered. Useful when your database has fixed-length fields.
The 'pattern' attribute uses a regular expression to define the allowed format. It enables pattern-based validation.
The 'autocomplete' attribute lets the browser suggest values based on previously entered data. It can be 'on' or 'off'.
The 'autofocus' attribute automatically sets the focus on the specified input field when the page loads. It should only be used on one field per page.
✨ Ask Lara — your AI study partner
Unlock personalized learning support. Lara can explain lessons, summarize topics, and answer your study questions — available from the Go plan and above.
Lara helps you learn faster — exclusive to ReadyTools Go, Plus, and Max members.