label (HTML attribute)

Spec
Depr. Version
No HTML 2
Browser support (more…)
IE7+ FF3.5 SA1.3+ OP10+ CH2+
Full None Full Full Full

Syntax

label="string"

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.

Figure 1. optgroup and option label rendering in IE, Firefox, Opera, and IE5 (Mac) Optgroup and option labels in different browsers

Example

This label 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 Chrome
5.5 6.0 7.0 8.0 1.0 1.5 2.0 3.0 3.5 1.3 2.0 3.1 4.0 9.2 9.5 10.0 2.0
None None Full Full None None None None None Full Full Full Full None None Full Full

This attribute is poorly supported and has limited practical value.

User-contributed notes

There are no comments yet.

Related Products