HTML Input Attributes Tutorial | Learn HTML Input Tags Attribute with WDH

HTML Input Attributes


HTML Input Attributes

Value Attribute :

The value attribute works differently on different input types.

for Button, the value attribute specifies the text on the button element.

for passwords, the value attribute specifies the initial value of the input field.

Output :

Read-only Attribute

The read-only attribute is a restriction attribute that we use to restrict HTML elements that its value can only be read and cannot be changed.

Output :

 

Size Attribute

The size attribute is a restriction attribute that we use to define/restrict the width of input field measured by characters.

Output :

Max length Attribute

Max length attributes specify the maximum number of characters are allowed in the input element.

It is used on input type search, text, URL, tel, email.

Output :

Max length Attribute

Max length attributes specify the maximum number of characters are allowed in the input element.

It is used on input type search, text, URL, tel, email.

Output :

Step attributes

 

The step attribute is a restriction attribute that we use to define valid steps that we can use for the input field.

Output :

Autocomplete:

It permits or disables autocomplete in the tag.

Value is on or off.

Output :

Autofocus:

specifies Associate in Nursing that an element should automatically get focus when the page loads.

Output :

Placeholder attribute:

Lastly, let's look at including some placeholder or a default value in our input boxes. To do that use placeholder attributes.

Placeholder attribute used like suggested text appears in the box.

Output :

Required attribute:

Next, we can further enhance our form, by making any of the input fields compulsory because of the submitting of the form.

So to make a particular field compulsory, we can add the required attribute It's an input element.

Output :