HTML标签

HTML <optgroup>标签

HTML <optgroup>标签作用

HTML <optgroup>标签用于在<select>元素内的下拉列表中对相关的<options>进行分组。
将<optgroup>标签与<select>结合使用,可以更轻松地访问下拉列表,尤其是当列表具有大量选项时。

语法

<optgroup label=" ">........</optgroup>
以下是有关HTML <optgroup>标签的一些规范
显示 内联
开始标签/结束标签 开始标签和结束标签
用法 表格和输入

示例

<!DOCTYPE html>
<html>
<head>
<title>Optgroup Tag</title>
<style>
body{
text-align: center;
}
select{
font-size:20px;
font-weight:bold;
color:green;
}
</style>
</head>
<body>
<h2>Example of optgroup tag</h2>
<label>Select your favourite brand</label><br>
<select>
<optgroup label="Laptop Maufacturur">
<option value="dell">Dell</option>
<option value="hp">HP</option>
<option value="lenovo">Lenovo</option>
<option value="acer">Acer</option>
</optgroup>
<optgroup label="Mobile Manufacturer">
<option value="apple">Apple</option>
<option value="nokia">Nokia</option>
<option value="samsung">Samsung</option>
<option value="coolpad">Coolpad</option>
</optgroup>
</select>
</body>
</html>
输出:
 HTML optgroup标签

属性:

标签专用属性:

属性 说明
disabled disabled 如果已设置,则该optgroup的选项将被禁用。
label text 它定义了将在下拉列表中显示的组的标签。它是必填属性。

全局属性:

HTML <optgroup>标签支持HTML中的全局属性

事件属性:

HTML <optgroup>标签支持HTML中的事件属性。

支持浏览器

标签  chrome浏览器  ie浏览器  firefox浏览器 Opera浏览器  Safari浏览器
<optgroup>
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4