Open In App
Related Articles

How to specify that an option-group should be disabled in HTML5 ?

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

We will use <optgroup> and <option> tags to create an option-group list and use the 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 items that exist. The <option> tag in HTML is used to choose an option from a drop-down menu. 

Syntax:

<optgroup label="">
    <option label="">  </option>
</optgroup>

Example: In this example, we are using the above-explained method.

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:



Last Updated : 15 May, 2023
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads