label (HTML attribute)
| Depr. | Version |
|---|---|
| No | HTML 2 |
| IE7+ | FF2 | SA1.3+ | OP9.5 |
|---|---|---|---|
| Full | None | Full | None |
Syntax
Description
The
label attribute provides a means for presenting a
shortened version of an option when it appears within
an optgroup (which, depending on the browser, may
display in a hierarchical layout or some other modified layout). The
optgroups rendering is shown in Figure 1.
optgroup and option label
rendering in IE, Firefox, Opera, and IE5 (Mac)
Example
Thislabel
attribute presents a simpler version of the option
content:<form>
<label for="favoritefood">Favorite food</label>
<select name="favoritefood" id="favoritefood">
⋮
<optgroup label="Vegetables">
<option label="Cabbage">Cabbage (local produce)</option>
<option label="Lettuce">Lettuce (local produce)</option>
<option label="Beans">Beans (tinned)</option>
<option label="Onions">Onions (local produce, non-GM)</option>
</optgroup>
⋮
</select>
</form>
Value
This attribute takes an abbreviated
version of the option content.
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.0 | 1.5 | 2.0 | 1.3 | 2.0 | 3.0 | 9.2 | 9.5 |
| None | None | Full | None | None | None | Full | Full | Full | None | None |
This attribute is poorly supported and has limited practical value.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.