CKTIS / HTML
selectedcontent — contents of the selected option
The `selectedcontent` element reflects the selected `option` contents inside a `select` control's button, without manually copying them with JavaScript.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<select><button><selectedcontent></selectedcontent></button><option>Text</option></select>Place selectedcontent inside the button that is the first element child of select. That button may contain one such element. Both tags are required; authors leave the element empty. It supports global attributes.
The browser deeply clones the selected option's child nodes rather than moving the originals. It does not copy its label attribute. Having no selected option clears the contents, while the presence of multiple stops updates. Elements script, SVG script, frame, iframe, embed, and object are removed from the clone.
In the example, setting select.value to "pear" should update the copy, producing pear | Pear. This is the expected result in an implementation supporting the feature, not a guarantee of compatibility in every browser. Check the behavior locally before deployment.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>selectedcontent demo</title>
<label for="fruit">Fruit</label>
<select id="fruit">
<button><selectedcontent id="preview"></selectedcontent></button>
<option value="apple" selected>Apple</option>
<option value="pear">Pear</option>
</select>
<pre id="result"></pre>
<script>
window.addEventListener("load", () => {
const select = document.getElementById("fruit");
const preview = document.getElementById("preview");
select.value = "pear";
document.getElementById("result").textContent =
`${select.value} | ${preview.textContent}`;
});
</script>
</html>Result
pear | Pear
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.