HTML disabled Attribute

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that the element should be disabled.

A disabled element is unusable.

The disabled attribute can be set to keep a user from using the element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the element usable again.

Applies to

The disabled attribute can be used on the following elements:

Examples

Button Example

A disabled button:

<button type="button" disabled>Click Me!</button>

Fieldset Example

Disable a group of related form elements:

<fieldset disabled>
<legend>Personalia:</legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>

Input Example

An HTML form with a disabled input field:

<form action="/action_page.php">
First name: <input type="text" name="fname"><br>
Last name: <input type="text" name="lname" disabled><br>
<input type="submit" value="Submit">
</form>

Optgroup Example

A disabled option-group:

<select>
<optgroup label="German Cars" disabled>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</optgroup>
</select>

Option Example

A drop-down list with one disabled option:

<select>
<option value="volvo" disabled>Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi">Audi</option>
</select>

Select Example

A disabled drop-down list:

<select disabled>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="audi">Audi</option>
</select>

Textarea Example

A disabled text area:

<textarea disabled>
Love makes Life Live.
</textarea>

Browser Support

The disabled attribute has the following browser support for each element:

Element          
button Yes Yes Yes Yes Yes
fieldset Yes Not supported Yes 7.0 Yes
input 1.0 6.0 1.0 1.0 1.0
optgroup 1.0 8.0 Yes Yes Yes
option 1.0 8.0 1.0 Yes Yes
select Yes Yes Yes Yes Yes
textarea Yes Yes Yes Yes Yes

Comments