Back to Content

HTMLOptGroupElement: label property

files/en-us/web/api/htmloptgroupelement/label/index.md

latest722 B
Original Source

{{ APIRef("HTML DOM") }}

The label property of the {{domxref("HTMLOptGroupElement")}} interface is a string value that reflects the {{htmlelement("optgroup")}} element's label attribute, which provides a textual label to the group of options.

Value

A string.

Examples

js
const optionGroup = document.getElementById("groupB");
console.log(optionGroup.label);
optionGroup.label = `${optionGroup.label} (${optionGroup.children.length})`;

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{htmlelement("optgroup")}}
  • HTML label attribute