How to specify that an option-group should be disabled in HTML5 ?
We will use <optgroup> and <option> tags to create an option-group list and use disabled attribute with <optgroup> to create a disabled option-group list. The <optgroup> tag is used to create a group of the same category options in a drop-down list. The <optgroup> tag is required when there is a long list of the item exists. The <option> tag in HTML is used to choose an option from a drop-down menu.
Syntax:
<optgroup label="">
<option label=""> </option>
</optgroup>Example:
HTML
<!DOCTYPE html><html> <head> <title> How to specify that an option-group should be disabled in HTML5? </title></head> <body style="text-align: center;"> <h1 style="color: green;"> GeeksforGeeks </h1> <h3> How to specify that an option-group<br> should be disabled in HTML5? </h3> <select> <optgroup label="Computer Programming" disabled> <option value="c">C</option> <option value="cpp">C++</option> <option value="java">Java</option> <option value="python">Python</option> </optgroup> <optgroup label="Web Technology"> <option value="html">HTML</option> <option value="css">CSS</option> <option value="js">JavaScript</option> <option value="jquery">jQuery</option> </optgroup> </select></body> </html> |
Output:

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML course.


