|
Non Selectable options in a drop down |
Its been a while since I learned any new HTML, but today I did.
Recently I was creating a list of two separate data sets, a primary list of high level countries, and a secondary list of less prominent countries.
So to separate the data I thought I'd stick an:
But that doesn't work! It still leaves your option as a selectable index.
Instead there is a tag, the 'optgroup' code. It turns out that you can wrap your group of options with this tag, and it inserts an unselectable option into the list!
2 <optgroup label="-------------------">
3 <option value="1">1</option>
4 <option value="2">2</option>
5 <option value="3">3</option>
6 </optgroup>
7 <optgroup label="--------------------">
8 <option value="A">A</option>
9 <option value="B">B</option>
10 <option value="C">C</option>
11 </optgroup>
12</select>