References

Beginner-friendly references for web development, with live, editable examples.

The HTML disabled attribute

Attribute All modern browsers
In short

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

Live 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 pattern set, 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 href when a link should be inactive.

Frequently asked questions

What does the disabled attribute do?
Disables a form control.
Are HTML form attributes enough for validation?
They give instant feedback, but client-side checks can be bypassed, so always validate on the server too.
Do form controls still need a label?
Yes. Every control needs a <label> for an accessible name, whatever attributes you set.
Which elements use the disabled attribute?
It is an element-specific attribute, used on form controls such as <input>, <button>, <select>, <textarea>, <option>, <optgroup> and <fieldset>.