Introduction to the use of select optgroup tag in html

Introduction to the use of select optgroup tag in html
Occasionally, I need to group select contents. In the past, I used program control. Today, I found that there is an optgroup attribute in select that can be used.

It has been tested and is 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 properties, you can't use the normal font, but you can change the color and size. In IE, the default is italic and bold


Copy code
The code is as follows:

<select name="bid" id="brand_3">
<option value="">Please select a brand</option>
<optgroup label="A"></optgroup>
<option value="693" custom="693">A AC BMW</option>
<option value="62" custom="62">A Aston Martin</option>
<option value="1" custom="1">A Audi</option>
<optgroup label="B"></optgroup>
<option value="723" custom="723">B Babos</option>
<option value="44" custom="44">B Porsche</option>
<option value="582" custom="582">B Baojun</option>
<option value="20" custom="20">B BMW</option>
<option value="593" custom="593">B Beijing Auto</option>
<option value="643" custom="643">B BAIC Weiwang</option>
<option value="122" custom="122">B BAIC Manufacturing</option>
<option value="4" custom="4">B Mercedes-Benz</option>
</select>

<<:  Vue+openlayer5 method to get the coordinates of the current mouse slide

>>:  CSS achieves the effect of changing the color of the entire line when the mouse is placed on it

Recommend

Implementing WeChat tap animation effect based on CSS3 animation attribute

Seeing the recent popular WeChat tap function, I ...

Detailed explanation of HTML form elements (Part 1)

HTML forms are used to collect different types of...

You may need a large-screen digital scrolling effect like this

The large-screen digital scrolling effect comes f...

The use of textarea in html and common problems and case analysis

The textarea tag is an HTML tag that we often use....

No-nonsense quick start React routing development

Install Enter the following command to install it...

Pycharm2017 realizes the connection between python3.6 and mysql

This article shares with you how to connect pytho...

CSS and JS to achieve romantic meteor shower animation

1. Rendering 2. Source code HTML < body > &...

Detailed steps for using jib for docker deployment in Spring Cloud

Introduction to Jib Jib is a library developed by...

Introduction to HTML Chinese Character Encoding Standard

In HTML, you need to specify the encoding used by...

How to deploy Rancher with Docker (no pitfalls)

Must read before operation: Note: If you want to ...

JavaScript to implement checkbox selection or cancellation

This article shares the specific code of JavaScri...

JavaScript to achieve slow motion animation effect

This article shares the specific code for JavaScr...

Docker build PHP environment tutorial detailed explanation

Docker installation Use the official installation...

Vue3 manual encapsulation pop-up box component message method

This article shares the specific code of Vue3 man...