HTML disabled Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The disabled attribute is a boolean that makes a form control not editable, not focusable, and not submitted. Users cannot click or tab into it; browsers usually show it grayed out.

It works on <button>, <input>, <select>, <textarea>, <option>, <optgroup>, and <fieldset>. Prefer it when a control must be fully inactive; use readonly when the value must still be submitted.

Baseline · Widely available.

Not deprecated and not experimental. Long-supported boolean attribute on form-associated elements.

Not submitted.

Disabled controls are left out of form data. If the server still needs the value, use readonly or a hidden input instead.

HTML Syntax

syntax.html
<input type="text"  disabled>

Boolean form: write disabled alone (or disabled="" / disabled="disabled"). In JavaScript: element.disabled = true.

Attribute Values

Boolean only — presence turns the control off:

ValueDescriptionTry it
disabled (present)No edit, no focus, not submitted; often grayed outTry it
(absent)Enabled — unless a parent fieldset (or similar) disables itTry it
vs readonlyreadonly can still focus and submit; disabled cannotTry it
fieldset disabledDisables descendant controls (legend exception per HTML)Try it

Live Preview

Toggle disabled on the input and button. Try focusing or typing when disabled.

Applies to both the text field and the action button below.

Controls

input.disabled = true · button.disabled = true

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Disable an Input and a Button

Presence of disabled turns the control off completely.

HTML
<label for="email">Email</label>
<input id="email" type="email" name="email" value="[email protected]" disabled>

<button type="submit" disabled>Submit</button>
Try It Yourself

How It Works

  1. Add disabled to the control — no value needed.
  2. Browser grays it out and blocks pointer/keyboard use.
  3. No focus via Tab or click.
  4. Not in form data if this sits inside a submitted form.

Example 2 — disabled vs readonly

Same visible value — different focus and submit rules.

HTML
<label for="a">Disabled (not submitted)</label>
<input id="a" name="a" value="keep-me" disabled>

<label for="b">Readonly (still submitted)</label>
<input id="b" name="b" value="keep-me" readonly>
Try It Yourself

How It Works

  1. disabled — immutable, unfocusable, omitted from submit.
  2. readonly — immutable, focusable, included on submit.
  3. Pick readonly when the user must see a locked value the server still needs.
  4. Pick disabled when the control must be fully inactive.

Example 3 — Disable a Whole Fieldset

One disabled on <fieldset> turns off the controls inside.

HTML
<fieldset disabled>
  <legend>Employment</legend>
  <label for="job">Job title</label>
  <input id="job" name="job" type="text">
  <label for="start">Start date</label>
  <input id="start" name="start" type="date">
</fieldset>
Try It Yourself

How It Works

  1. fieldset disabled disables descendant form controls.
  2. You do not need disabled on every nested input.
  3. HTML exception: controls inside the <legend> are not disabled by the fieldset flag.
  4. Re-enable by removing the attribute (or setting fieldset.disabled = false).

Edge Cases & Pitfalls

Most bugs come from expecting a disabled value on the server or mixing it with validation attributes.

submit

Values are omitted

Never rely on a disabled field arriving in POST/GET data. Mirror it with a hidden input if needed.

validation

required has no effect

Disabled controls skip constraint validation. Do not combine required with disabled on inputs.

a11y

Explain why it’s off

Gray alone is not enough. Add nearby text (or enable the control) so users know how to proceed.

firefox

Button state may persist

Firefox can keep a dynamically disabled <button> state across reloads. Use autocomplete to control that behavior if needed.

css

Style with :disabled

Supporting elements with the attribute match :disabled; without it they match :enabled.

Browser Support

disabled is an HTML attribute for form controls in the browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

disabled

Supported everywhere modern browsers run. Behavior (no focus, no submit, gray styling) is consistent across Chrome, Firefox, Safari, and Edge.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet Modern
Full support
Internet Explorer All
Supported
disabled Widely supported

Bottom line: Safe to use on all form UIs. Remember disabled values never reach the server — plan readonly or hidden fields when you still need the data.

Key Takeaways

  • Boolean: presence disables the control — no focus, no edit, no submit.
  • Elements: button, input, select, textarea, option, optgroup, fieldset.
  • vs readonly: readonly still focuses and submits.
  • fieldset disabled turns off nested controls in one step.

One line: disabled fully deactivates a control — use readonly when the value must still be sent.

Frequently Asked Questions

It makes a form control not editable, not focusable, and not submitted with the form. Browsers usually gray it out and ignore clicks and focus.
button, fieldset, input, optgroup, option, select, and textarea. A disabled fieldset disables its descendant form controls (with a legend exception).
Yes. Presence means disabled. Write disabled or disabled="". In JavaScript use element.disabled = true or false.
readonly blocks editing but the control stays focusable and its value is still submitted. disabled blocks interaction and excludes the value from submission.
No. Disabled controls are not successful controls, so their values are omitted from the form data set.
No. A disabled control does not take part in constraint validation, and required must not be used together with disabled on inputs.

Next: download

Hint that a link should download a file, optionally with a filename.

download tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful