Home >Web Front-end >HTML Tutorial >html: Detailed explanation of the use of optgroup tags

html: Detailed explanation of the use of optgroup tags

黄舟
黄舟Original
2017-07-03 09:31:461810browse

Occasionally, I need to group the select content. In the past, I used program control. Today I found that there is an optgroup attribute that can be used in select.

It has been tested and suitable for browsers such as firefox and ie. The only shortcoming found so far is that the title style after the group cannot be customized. For example: If you want to change the font attributes, you cannot use a normal font, but you can change the color and size. The default under IE is italic and bold

The code is as follows:

<select name=bid id=brand_3>
<option value=>请选择品牌</option>
<optgroup label=a></optgroup>
<option value=693 custom=693>a ac宝马</option>
<option value=62 custom=62>a 阿斯顿马丁</option>
<option value=1 custom=1>a 奥迪</option>
<optgroup label=b></optgroup>
<option value=723 custom=723>b 巴博斯</option>
<option value=44 custom=44>b 保时捷</option>
<option value=582 custom=582>b 宝骏</option>
<option value=20 custom=20>b 宝马</option>
<option value=593 custom=593>b 北京汽车</option>
<option value=643 custom=643>b 北汽威旺</option>
<option value=122 custom=122>b 北汽制造</option>
<option value=4 custom=4>b 奔驰</option>
</select>

The above is the detailed content of html: Detailed explanation of the use of optgroup tags. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn