HTML - attributes - disabled

revision:


Content

"disabled" attribute : boolean attribute that disables an element syntax some examples


"disabled" attribute : boolean attribute that disables an element

top

When present, it specifies that the element should be disabled. A disabled element is unusable. The disabled attribute can be set to keep a user from using the element until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the element usable again.

The disabled attribute can be used on the following elements: <button>, <fieldset>, <input>, <optgroup>, <option>, <select>, <textarea>.


syntax

top

<element disabled></element>

Disabled <input> elements in a form will not be submitted! The disabled attribute is usually drawn with grayed-out text. If the element is disabled, it does not respond to user actions, it cannot be focused.


some examples

top




codes:
                    <button style="margin-left:5vw;" type="button" disabled>Click Me!</button>
                    <br><br>
                    <form style="margin-left:5vw;" action="action_page.php">
                        <label for="cars">Choose a car:</label>
                        <select name="cars" id="cars" disabled>
                        <option value="volvo">Volvo</option>
                        <option value="saab">Saab</option>
                        <option value="mercedes">Mercedes</option>
                        <option value="audi">Audi</option>
                        </select>
                        <br><br>
                        <input type="submit" value="Submit">
                    </form>
                
Personalia:







codes:
                    <form style="margin-left:5vw;">
                        <form style="margin-left:5vw;" action="action_page.php">
                        <fieldset disabled>
                            <legend>Personalia:</legend>
                            <label for="fname">First name:</label>
                            <input type="text" id="fname" name="fname"><br><br>
                            <label for="lname">Last name:</label>
                            <input type="text" id="lname" name="lname"><br><br>
                            <label for="email">Email:</label>
                            <input type="email" id="email" name="email"><br><br>
                            <label for="birthday">Birthday:</label>
                            <input type="date" id="birthday" name="birthday"><brs><br>
                            <input type="submit" value="Submit">
                        </fieldset>
                        </form>
                    </form>