HTML <input> type Attribute (original) (raw)

Last Updated : 12 Mar, 2024

The **HTML type Attribute is used to specify the type of element to display. The default type of type attribute is text.

**Syntax:

**Attribute Values:

Name Description
button Defines clickable button in HTML document, commonly activated with JavaScript scripts.
checkbox HTML input field for selecting one or more limited options.
color It is used to define a color picker. The value should be a seven-character hexadecimal notation. Its default value is #000000(black).
date HTML input element for selecting dates with year, month, and day.
email HTML field for entering email addresses, automatically validated for format.
file It is used to specify the file select field and add a button to choose a file for upload to the form.
hidden Hidden field: Input element in forms, conceals data from users, facilitating backend operations without user interaction, typically for database updates.
image It is used to define an image as the submit button.
month It is used to specify the control of month and year field. The value must be in the format of "YYYY-MM".
number It is used to specify an input field for entering a number.
password Input tag attribute for sensitive data; should be transmitted securely (HTTPS) due to its sensitivity.
radio input element with type=radio, allows single selection from predefined options in forms.
range Control for user-entered numbers, allows setting restrictions, default range typically 0 to 100.
reset It is used to defines a reset button. The reset button is used to reset all the form values to its initial values.
search It is used to define a text field that entered a search string.
submit Triggers submission of user-input values to form handler, typically activating server-side processing script.
tel It is used to define a field that entering a user telephone Number.
text It is used to define a single-line text field . The default width of the text field is 20 characters.
time It is used to specify the entering time control field.
url It is used to define a field that entered a URL. This input value is automatically validated before submitted the form.
week It is used to define a week and a year control field.

HTML type Attribute Examples

**Example: In this example we have HTML form for username and password input with submit and reset buttons. Input type attributes: "text" for username, "password" for password.

html `

HTML input type Attribute

<form action="#" method="get">
    Username: <input type="text" name="uname">
    <br><br>
    Password: <input type="password" name="pwd">
    <br><br>
    <button type="submit" value="submit">
        Submit
    </button>
    <button type="reset" value="reset">
        Reset
    </button>
</form>

`

**Output:

HTML-input-type-Attribute

HTMl Input Tye Attribute

**Supported Browsers: The browsers supported by HTML type attribute are listed below: