<input> Tag
The <input> tag is one of the most important HTML form elements.
It is used to create different types of input fields where users can enter or select data.
The behavior of the tag depends on its type attribute. By changing the value of type, the same tag can create a text box, password field, email field, radio button, checkbox, file upload, and many other input controls.
Syntax:
<input type="value">
The type Attribute
- The type attribute defines what kind of input field the browser should display.
There are many input types available. The most commonly used ones are:
- text
- password
- number
- date
- radio
- checkbox
- file
- submit
- reset
- button
type="text"- Creates a single-line text box.
<input type="text">
type="password"- Creates a password field where the entered characters are hidden.
<input type="password">
type="email"- Accepts email addresses and performs basic email validation.
<input type="email">
type="number"- Allows users to enter only numeric values.
<input type="number">
type="date"- Displays a calendar for selecting a date.
<input type="date">
type="radio"- Allows users to select only one option from a group.
<input type="radio" name="gender"> Male
<input type="radio" name="gender"> Female
type="checkbox"- Allows users to select multiple options.
<input type="checkbox"> HTML
<input type="checkbox"> CSS
<input type="checkbox"> JavaScript
type="file"- Allows users to upload files from their device.
<input type="file">
type="submit"- Creates a button that submits the form data to the server.
<input type="submit" value="Register">
type="reset"- Creates a button that clears all form fields.
<input type="reset" value="Clear">
type="button"- Creates a normal button. It does not submit the form unless JavaScript is added.
<input type="button" value="Click Me">
Top comments (0)