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

html: Detailed explanation of the use of optgroup tags

黄舟
Release: 2017-07-03 09:31:46
Original
1816 people have browsed it

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>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template