HTML <optgroup> Tag
Description
The <optgroup>
HTML element is a container inside which the <option>
elements are combined into one group. The peculiarity of <optgroup>
is that it does not stand out as a regular list item, it is accented with a bold style, and all elements included in this container are shifted to the right of its original position.
Properties
- Permitted Parents
- A
<select>
element - Content
- One or more
<option>
elements - Start/End Tags
- Start tag: required, End tag: required
Example
<select>
<optgroup label="Fruits">
<option value="banana">Banana</option>
<option value="orange">Orange</option>
<option value="apple">Apple</option>
</optgroup>
<optgroup label="Vegetables">
<option value="carrot">Carrot</option>
<option value="tomato">Tomato</option>
<option value="onion">Onion</option>
</optgroup>
</select>
Attributes
Attribute | Definition |
---|---|
label | Specifies a label for the option group. |
disabled | Disables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing. |
Global Attributes
The <optgroup>
tag also supports the Global Attributes in HTML5
Event Attributes
The <optgroup>
tag also supports the Event Attributes in HTML5
Browser Support
Desktop | |||||
5.5 | Yes | 1 | 1 | Yes | Yes |
Tablets / Mobile | |||||
![]() |
|||||
Yes | Yes | 4 | Yes | Yes | Yes |
Last updated by CSSPortal on: 6th December 2019
HTML Tags
- a
- abbr
- address
- area
- article
- aside
- audio
- b
- base
- bdi
- bdo
- blockquote
- body
- br
- button
- canvas
- caption
- cite
- code
- col
- colgroup
- comment
- datalist
- dd
- del
- details
- dfn
- dialog
- div
- dl
- doctype
- dt
- em
- embed
- fieldset
- figcaption
- figure
- footer
- form
- h1
- h2
- h3
- h4
- h5
- h6
- head
- header
- hr
- html
- i
- iframe
- img
- input
- ins
- kbd
- keygen
- label
- legend
- li
- link
- map
- mark
- menu
- meta
- meter
- nav
- noscript
- object
- ol
- optgroup
- option
- output
- p
- param
- picture
- pre
- progress
- q
- rp
- rt
- ruby
- s
- samp
- script
- section
- select
- small
- source
- span
- strong
- style
- sub
- summary
- sup
- table
- tbody
- td
- textarea
- tfoot
- th
- thead
- time
- title
- tr
- track
- u
- ul
- var
- video
- wbr