HTML - Optgroup element (Group of Option)

About

optgroup is an HTML element that group options within a select element.

Example

<label for="country">Choose a country:</label>
<select id="country">
    <optgroup label="Europa">
        <option>England</option>
        <option>Germany</option>
        <option>Netherland</option>
    </optgroup>
    <optgroup label="Africa">
        <option>Marroco</option>
        <option>Algeria</option>
        <option>Tunisia</option>
    </optgroup>
</select>

Documentation / Reference





Discover More
HTML - Option

option is an element used to define a value. option can be contained in: a select (list) an optgroup (to group option) or a datalist element (data array) For example, this select creates a...
How to use the Select HTML Element?

select is an HTML control form element used for selecting one or more value amongst a set of options. It creates a drop-down list used in a form that will set a scalar value from a list of options. ...
What are Form Control elements in HTML ?

control form elements are elements that are used specifically inside a form. They are used: to specify a key and a value. to layout the form to submit it or reset it field set [optional]...
What is an HTML Form?

form is an element that represents a user-submittable form. When parsed as HTML, a form element's start tag will imply a p element's end tag just before. The pizza order form (taken from the...



Share this page:
Follow us:
Task Runner