HTML input Tag disabled Attribute Tutorial

In this section, we will learn what the disabled attribute is and how to use it.

What is disabled Attribute in HTML <input> Tag?

The disabled attribute is used when we want to disable an input field and stop users from using it!

For example, let’s say you have a submit button in a form. You want users to only hit this button once all the input fields of that form are filled with accurate data! So with the help of the disabled attribute, we can disable the submit button as long as all the fields are not complete!

So in short, after applying this attribute to an input, that input becomes gray, which signals users that this field is unusable.

HTML disabled Attribute in <input> Tag Syntax:

<input type = “type” disabled>

<input> Tag disabled Attribute Values

The disabled attribute is a Boolean attribute and that means there’s no value to it! Simply put, the attribute in the target input element and that becomes disabled.

Example: using disabled attribute in HTML <input> tag

See the Pen using disabled attribute in HTML <input> tag by Omid Dehghan (@odehghan) on CodePen.

For this example, both username and password fields are disabled with the help of the disabled attribute.


Top Technologies