Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

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:

Elements Attribute
<button> disabled
<fieldset> disabled
<input> disabled
<optgroup> disabled
<option> disabled
<select> disabled
<textarea> disabled

Examples

Button Example

A disabled button:

<button type="button" disabled>Click Me!</button>
Try it Yourself »

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>
Try it Yourself »

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>
Try it Yourself »

Optgroup Example

A disabled option-group:

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

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>
Try it Yourself »

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>
Try it Yourself »

Textarea Example

A disabled text area:

<textarea disabled>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>
Try it Yourself »

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

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.