The HTML disabled attribute
The HTML disabled attribute disables the control so it cannot be interacted with or submitted. It is used on form controls such as <input>, <button>, <select>, <textarea>, <option>, <optgroup> and <fieldset>.
Overview
The disabled attribute disables the control so it cannot be interacted with or submitted. It applies to form controls such as <input>, <button>, <select>, <textarea>, <option>, <optgroup> and <fieldset>.
A disabled control is skipped in the tab order, not submitted, and styled grayed-out. Disabling a <fieldset> disables the controls inside it, except those in its first <legend>. If you need it focusable/announced, use aria-disabled instead.
Syntax
<button disabled>Unavailable</button>
Values
| Value |
|---|
| A boolean attribute: present or absent. |
Example
<button disabled>Can't click</button> <input value="Locked" disabled style="padding:8px;">
Best practices
- A
disabled<fieldset> leaves the controls inside its first <legend> enabled. That makes the legend the right place for a checkbox that switches the rest of the group on and off. - A disabled field can't hold back the form, even with required or
patternset, because disabled controls are barred from constraint validation. - Disabling the control that has focus, such as a submit button while a request runs, moves focus to the document body. Move focus somewhere useful before you set the attribute.
- When the server still needs a value that users shouldn't change, use readonly rather than disabled. It works on <textarea> and typed inputs such as text, email, number and date, and those fields stay focusable and are submitted.
- Links can't be switched off with this attribute. It isn't valid on <a> and doesn't stop clicks there, so remove the
hrefwhen a link should be inactive.
Frequently asked questions
What does the disabled attribute do?
Are HTML form attributes enough for validation?
Do form controls still need a label?
Which elements use the disabled attribute?
<input>, <button>, <select>, <textarea>, <option>, <optgroup> and <fieldset>.






















