- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - disabled Attribute
The HTML disabled attribute is used to specify that the element is disabled. It is a Boolean attribute. Using this attribute, we can disable the whole form controls such as input elements, buttons, options, textarea, fieldset, etc.
It can be used on the following elements: <input> , <fieldset>, <button>, <textarea>, <select>, <option> and <optgroup> etc.
Syntax
Following is the syntax for HTML disabled attribute −
<input disabled>
Example
In the following example, we are going to use the disabled attribute with the input field.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML disabled attribute</title> </head> <body> <!--example of the 'disabled' attribute--> <p>'disabled' attribute with input element.</p> Text(disabled): <input type="text" placeholder="Disabled" disabled> <input type="text" placeholder="Not disabled"> <br> Checkbox(disabled): <input type="checkbox" disabled> <input type="checkbox">Not disabled <br> Radio(disabled): <input type="radio" disabled> <input type="radio">Not disabled </body> </html>
When we run the above code, it will generate an output consisting of the input fields some are mentioned with disabled attribute displayed on the webpage.
Example
Considering the another scenario, where we are going to use the disabled attribute with the button element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML disabled attribute</title> </head> <body> <!--example of the 'disabled' attribute--> <p>'disabled' attribute with button element.</p> <button disabled>Disabled</button> <button>Not Disabled</button> </body> </html>
On running the above code, the output window will pop up displaying the buttons out of one i mentioned with disabled attribute on the webpage.
Example
Let's look at the following example, where we are going to use the disabled attribute with the fieldset element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML disabled attribute</title> </head> <body> <!--example of the 'disabled' attribute--> <p>'disabled' attribute with fieldset element.</p> <fieldset disabled> <legend>Login Form</legend> Username: <input type="text" placeholder="username"> <br> Password: <input type="password" placeholder="password"> <br> <button>Login</button> </fieldset> </body> </html>
When we run the above code, it will generate an output consisting of the input field in the fieldset that are disabled displayed on the webpage.
Example
Following is the example, where we are going to use the disabled attribute with the select and option element.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML disabled attribute</title> </head> <body> <!--example of the 'disabled' attribute--> <p>'disabled' attribute with select and option element.</p> <!--disabled option--> <select> <option>HTML</option> <option disabled>CSS</option> <option>JavaScript</option> </select> <!--disabled select--> <select disabled> <option>HTML</option> <option>CSS</option> <option>JavaScript</option> </select> </body> </html>
On running the above code,the output window will pop up displaying the dropdown menu out of one is disabled on the webpage.
To Continue Learning Please Login
Login with Google