Advertisement
Home Open Editor ❯

HTML <option> label Attribute

Example

<label for="lang">Choose a language:</label>

<select id="lang">
  <option label="HTML">HTML</option>
  <option label="CSS">CSS</option>
  <option label="JavaScript">JavaScript</option>
</select>

Try this code ❯

Meaning

The label attribute contains a short label that might be more appealing to use when the selection list is rendered as a hierarchy due to the presence of an <optgroup> element.

If the label attribute isn't defined, its value is that of the element text content.


Standard Syntax

<option label="text">text</option>


Advertisement

Attribute Values

Value Description
text The textContent of the element.
Home Open Editor ❯
Advertisement