W3cubDocs

/Web APIs

HTMLOptionElement: text property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨July 2015⁩.

The text property of the HTMLOptionElement represents the text inside the <option> element. This property represents the same information as Node.textContent.

Note: If the element has a label, the text inside the <option> is not visually rendered. In this case, the text property can still be used to set the content, but it will have no visible effect.

Value

A string.

Example

const optionElement = document.getElementById("exampleOption");
console.log(`Text property: ${optionElement.text}`);
optionElement.text = "Updated text";

Specifications

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on IOS Samsung Internet WebView Android WebView on iOS
text 1 12 1 ≤12.1 3 18 4 ≤12.1 1 1.0 4.4 1

See also

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOptionElement/text