Advertisement

Google Ad Slot: content-top

Input attributes

~1 min read · HTML
On this page

HTML input elements support a wide range of attributes that allow developers to customize the behavior, appearance, and functionality of form fields. Here’s a comprehensive list of commonly used input attributes and their purposes:

Common HTML Input Attributes

Type:

type: Specifies the type of input (e.g., text, password, email, etc.).

Name:

name: Defines the name of the input, which is used to reference the data on form submission.

Value:

value: Specifies the default value of the input field.

Placeholder:

placeholder: Displays a short hint that describes the expected value of the input.

Required:

required: Ensures that the input must be filled before submitting the form.

Disabled:

disabled: Disables the input field, preventing user interaction.

Readonly:

readonly: Makes the input field read-only, so users cannot change its value.

Maxlength:

maxlength: Limits the maximum number of characters allowed in the input.

Min and Max:

min and max: Defines the minimum and maximum values for inputs of types like number, range, date, etc.

Step:

step: Specifies the increment for numerical inputs.

Autocomplete:

autocomplete: Controls whether the browser should auto-fill the input based on previous entries (on or off).

Autofocus:

autofocus: Automatically focuses the input when the page loads.

Pattern:

pattern: Defines a regular expression pattern that the input's value must match for validation.

Multiple:

multiple: Allows multiple values for inputs of types like email or file.

Size:

size: Specifies the visible width (in characters) of the input.

Minlength:

minlength: Specifies the minimum number of characters required for input.

List:

list: Connects the input to a <datalist> element to provide predefined options.

Accept:

accept: Specifies the file types allowed when using input type="file".

Height and Width:

height and width: Specifies the size of an input type="image".

Novalidate:

novalidate: When added to a form, disables HTML5 form validation.