
2025-07-24 — By Siddharth Jain · 6 min read
The tag is a fundamental element in HTML, especially when you want to collect user data through a form. It supports various attributes that define its purpose, appearance, and behavior. Here’s a clear and beginner-friendly explanation of all important attributes.
The tag is used in forms to collect data from users. It allows you to create text fields, email fields, password boxes, date pickers, file uploads, checkboxes, radio buttons, sliders, and more.
typeDetermines what kind of input is expected.
| Value | Purpose |
|---|---|
| text | Single-line text |
| Email address | |
| password | Concealed (dots) password |
| number | Number only |
| date | Date picker |
| file | File upload |
| checkbox | Tick box |
| radio | Single choice (from many) |
| range | Slider input |
| submit | Submit button |
| reset | Form reset button |
nameGives a name to the field for form submission (used by the server).
<input type="text" name="username" />
valueSets the default or current value in the input box.
<input type="text" value="Hello" />
placeholderDisplays helper text that shows what the user should enter.
<input type="email" placeholder="Enter your email" />
requiredMakes the input field mandatory. The form cannot be submitted without filling this.
<input type="text" required />
readonlyShows the input, but the value cannot be changed by the user.
<input type="text" value="Read only" readonly />
disabledCompletely disables the input—users cannot interact with it.
<input type="text" disabled />
min and maxSet minimum and maximum values for number, date, or range fields.
<input type="number" min="1" max="100" />
<input type="date" min="2024-01-01" max="2025-12-31" />
maxlength and minlengthControl the maximum and minimum length of textual input.
<input type="text" maxlength="10" minlength="3" />
patternSpecifies a regular expression pattern the input value must match.
<input type="text" pattern="[A-Za-z]{3,}" title="At least 3 letters" />
stepDefines the increment between allowed values for number or range inputs.
<input type="number" min="0" max="10" step="2" />
autocompleteControls whether the browser should suggest autofill options for the input.
<input type="text" name="name" autocomplete="off" />
autofocusAutomatically focuses this field when the page loads.
<input type="text" autofocus />
multipleAllows selection of more than one value for file or email inputs.
<input type="file" multiple /> <input type="email" multiple />
Below is a complete example that demonstrates multiple `` attributes in a form:
<form>
<label>Email:</label>
<input
type="email"
name="user_email"
placeholder="example@mail.com"
required
maxlength="30"
autofocus
/>
<br />
<label>Password:</label>
<input type="password" name="user_pass" minlength="6" required />
<br />
<input type="submit" value="Login" />
</form>
type for the kind of input you need.name attributes so your backend can process the data.placeholder, required, and autocomplete.min, max, maxlength, and pattern to ensure data quality.readonly, disabled, and autofocus where suitable.With these attributes, you can build any kind of interactive web form you want—all in a simple, maintainable, and user-friendly way.