YouTip LogoYouTip

Att Input Disabled

## HTML `` disabled Attribute The `disabled` attribute is a boolean attribute used to specify that an `` element should be disabled. When an input element is disabled, it is non-interactive, meaning users cannot click, focus, or type into it. Additionally, its value is not submitted when the form is sent. --- ## Syntax In HTML, you can write the `disabled` attribute in its minimized form: ```html ``` ### XHTML Compatibility In XHTML, attribute minimization is forbidden. The `disabled` attribute must be defined with its value explicitly declared: ```html ``` --- ## Browser Support | Attribute | Chrome | Edge/IE | Firefox | Safari | Opera | | :--- | :--- | :--- | :--- | :--- | :--- | | **`disabled`** | Yes (All versions) | Yes (All versions) | Yes (All versions) | Yes (All versions) | Yes (All versions) | The `disabled` attribute is fully supported by all modern and legacy web browsers. --- ## Code Examples ### Basic Example The following example demonstrates an HTML form with a disabled "Last name" input field: ```html




``` ### Dynamic Control with JavaScript The `disabled` attribute is often toggled dynamically using JavaScript. For example, you can enable an input field only after a user checks a "Terms and Conditions" checkbox: ```html


``` --- ## Key Considerations and Best Practices ### 1. Form Submission Behavior * **Important:** Disabled `` elements **are not submitted** with the form. If you need to send a read-only value to the server during form submission, use the `readonly` attribute instead of `disabled`. ### 2. Difference Between `disabled` and `readonly` | Feature | `disabled` | `readonly` | | :--- | :--- | :--- | | **User Interaction** | Completely blocked (cannot focus, click, or select text). | Read-only, but the user can still focus and select/copy the text. | | **Form Submission** | The value is **not** sent to the server. | The value **is** sent to the server. | | **Styling** | Browsers automatically apply a grayed-out style. | Looks like a normal input by default unless styled with CSS. | ### 3. Limitations * The `disabled` attribute is not applicable to ``. ### 4. Accessibility (a11y) * Disabled elements are skipped during keyboard navigation (using the `Tab` key). * Screen readers will announce the element as "disabled" or "dimmed." Ensure your CSS provides sufficient color contrast if you override the default browser styling for disabled states.
← Att Input FormAtt Input Checked β†’