HTML | disabled Attribute
The disabled attribute in HTML indicates whether the element is disabled or not. If this attribute is set, the element is disabled. The disabled attribute is usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused. It is a boolean attribute.
Usage: It can be used on the following elements: <button>, <input>, <option>, <select>, <textarea>, <feildset> and <optgroup>.
Syntax:
<tag disabled></tag>
-
<button>: When the disabled attribute is present, it specifies that the button is disabled. A disabled button is unusable and un-clickable.
- Example:
<!DOCTYPE html><html><head><title>HTML disabled Attribute</title></head><bodystyle="text-align:center"><h1style="color: green;">GeeksforGeeks</h1><h2>HTML disabled Attribute</h2><!--A disabled button--><buttontype="button"disabled>Click Me!</button></body></html>chevron_rightfilter_none - Output:

- Example:
<!DOCTYPE html><html><head><title>HTML disabled Attribute</title></head><bodystyle="text-align:center"><h1style="color: green;">GeeksforGeeks</h1><h2>HTML disabled Attribute</h2><!--A disabled input--><label>Input:<inputtype="text"name="value"value="This input field is disabled"disabled></label></body></html>chevron_rightfilter_none - Output:

- Example:
<!DOCTYPE html><html><head><title>HTML disabled Attribute</title></head><bodystyle="text-align:center"><h1style="color: green;">GeeksforGeeks</h1><h2>HTML disabled Attribute</h2><!--A disabled input--><p>Volvo is disabled.</p><select><optionvalue="volvo"disabled>Volvo</option><optionvalue="saab">Saab</option><optionvalue="vw">VW</option><optionvalue="audi">Audi</option></select><br></body></html>chevron_rightfilter_none - Output:

-
Example:
<!DOCTYPE html><html><head><title>HTML disabled Attribute</title></head><bodystyle="text-align:center"><h1style="color: green;">GeeksforGeeks</h1><h2>HTML disabled Attribute</h2><!--A disabled input--><p>This select field is disabled.</p><selectdisabled><optionvalue="binary">Binary Search</option><optionvalue="linear">Linear Search</option><optionvalue="interpolation">Interpolation Search</option></select></body></html>chevron_rightfilter_none - Output:

- Example:
<!DOCTYPE html><html><head><title>HTML disabled Attribute</title></head><bodystyle="text-align:center"><h1style="color: green;">GeeksforGeeks</h1><h2>HTML disabled Attribute</h2><!--A disabled textarea--><textareadisabled>This textarea field is disabled.</textarea></body></html>chevron_rightfilter_none - Output:

- Example:
<!DOCTYPE html><html><head><title>HTML disabled Attribute</title></head><bodystyle="text-align:center"><h1style="color: green;">GeeksforGeeks</h1><h2>HTML disabled Attribute</h2><!--A disabled fieldset--><p>This field set is disabled.</p><fieldsetdisabled>Name: <inputtype="text"><br></fieldset></body></html>chevron_rightfilter_none - Output:

- Example:
<!DOCTYPE html><html><head><title>HTML disabled Attribute</title></head><bodystyle="text-align:center"><h1style="color: green;">GeeksforGeeks</h1><h2>HTML disabled Attribute</h2><!--A disabled optgroup--><select><optgrouplabel="German Cars"disabled><optionvalue="mercedes">Mercedes</option><optionvalue="audi">Audi</option></optgroup></select></body></html>chevron_rightfilter_none - Output:

- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
<input>: When the disabled attribute is present, it specifies that the input is disabled. A disabled inpit is unusable and un-clickable.
<option>: When the disabled attribute is present, it specifies that the option field is disabled. A disabled option is unusable and un-clickable.
<select>: When the disabled attribute is present, it specifies that the select field is disabled. A disabled select is unusable and un-clickable.
<textarea>: When the disabled attribute is present, it specifies that the textarea field is disabled. A disabled textarea is unusable and un-clickable.
<fieldset>: When the disabled attribute is present, it specifies that the fieldset is disabled. A disabled fieldset is unusable and un-clickable.
<optgroup>: When the disabled attribute is present, it specifies that the optgroup is disabled. A disabled optgroup is unusable and un-clickable.
Supported Browsers: The browser supported by disabled attribute are listed below:
Recommended Posts:
- HTML <select> disabled Attribute
- HTML <option> disabled Attribute
- HTML <input> disabled Attribute
- HTML <textarea> disabled Attribute
- HTML <fieldset> disabled Attribute
- HTML <optgroup> disabled Attribute
- HTML <button> disabled Attribute
- HTML | DOM Option disabled Property
- HTML | DOM Input URL disabled Property
- HTML | DOM OptionGroup disabled Property
- HTML | DOM Fieldset disabled Property
- HTML | DOM Button disabled Property
- HTML | DOM Select disabled Property
- HTML | DOM Textarea disabled Property
- HTML | DOM Link disabled Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



