HTML <selectedcontent> Tag

The <selectedcontent> element displays the contents of the currently selected <option> inside the first-child <button> of a <select>. It unlocks “customizable selects” where the closed button and the picker list can be styled separately.

The browser clones the selected option into <selectedcontent>. When the selection changes, that clone is replaced.

Limited availability.

Not Baseline. Support is still rolling out. Keep a usable plain <select> experience for other browsers.

Placement rule.

<button> must be the first child of <select>, and <selectedcontent> is the button’s child. Options follow the button.

HTML Syntax

syntax.html
<select><button><selectedcontent> </selectedcontent></button> …options…</select>

Both start and end tags are required. Authors usually leave the element empty; the browser fills it.

Attributes

<selectedcontent> has no element-specific attributes. Placement and CSS matter most:

Attribute / ideaDescriptionTry it
(none specific)Global attributes only; content is cloned from the selected optionTry it
PlacementInside first-child <button> of <select>Try it
CSS targetingStyle clones in the button separately from options in the picker (e.g. hide images in the button)Try it
Rich optionsOptions may include icons/markup that look different in button vs listTry it

Global Attributes

The <selectedcontent> tag also supports the Global Attributes in HTML.

Live Preview

Customizable select markup. In unsupported browsers you may see a normal select or empty button area.

Requires a supporting browser for the custom button clone. Fallback still selects options.

Preview

Basic customizable select structure

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Required Structure

Button first, <selectedcontent> inside it, then options.

HTML
<label for="lang">Language</label>
<select id="lang">
  <button type="button">
    <selectedcontent></selectedcontent>
  </button>
  <option value="html">HTML</option>
  <option value="css">CSS</option>
  <option value="js">JavaScript</option>
</select>
Try It Yourself

How It Works

  1. Put <button> first inside <select>.
  2. Nest empty <selectedcontent> as the button’s child.
  3. List <option>s after the button.
  4. Browser clones the selected option into the button face.

Example 2 — Hide Images in the Button

Style the clone without changing how options look in the picker.

HTML
<select class="icon-select">
  <button type="button">
    <selectedcontent></selectedcontent>
  </button>
  <option value="home">
    <img src="/images/codetofun-logo.png" alt="" width="16" height="16" />
    Home
  </option>
  <option value="docs">
    <img src="/images/codetofun-logo.png" alt="" width="16" height="16" />
    Docs
  </option>
</select>

<!-- CSS: selectedcontent img { display: none; } -->
Try It Yourself

How It Works

  1. Keep rich markup in options for the open picker.
  2. Target selectedcontent … to simplify the closed button.
  3. Hide bulky media in the button without removing it from the list.
  4. Test unsupported browsers where styling may not apply.

Example 3 — Text-Only Options Still Work

Even without icons, the structure documents the customizable pattern.

HTML
<label for="theme">Theme</label>
<select id="theme">
  <button type="button">
    <selectedcontent></selectedcontent>
  </button>
  <option value="light">Light</option>
  <option value="dark" selected>Dark</option>
  <option value="system">System</option>
</select>
Try It Yourself

How It Works

  1. Mark the initial selection with selected on an option.
  2. Clone updates on change as the user picks another option.
  3. Keep labels for accessibility.
  4. Progressively enhance — plain selects remain valid HTML.

Edge Cases & Pitfalls

order

Button not first

If the button is missing or not first, the browser may create an implicit button you cannot style via selectedcontent.

sync

Dynamic option edits

Clones update when selection changes. Mutating the selected option afterward may need a manual refresh.

inert

Inert button content

Content inside the select button is inert — no focusing nested controls inside the clone.

support

Limited browser support

Treat this as progressive enhancement. Unsupported engines still need a usable select.

css

Styling picker vs button

Button styles do not automatically restyle the open list. Target option content and selectedcontent separately.

frameworks

SPA option re-renders

Frameworks that rewrite option trees after paint can desync the clone. Re-select or trigger an update when needed.

Browser Support

The <selectedcontent> element is part of customizable selects with limited availability. It is not a Node.js, Deno, or Bun API.

✓ Limited availability

<selectedcontent>

Not Baseline. Available in some Chromium-based browsers as customizable selects ship; check current compatibility before relying on it in production.

35% Global support (approx.)
Google Chrome Recent
Partial / rolling
Mozilla Firefox —
Check latest
Apple Safari —
Check latest
Microsoft Edge Recent
Partial / rolling
Opera Recent
Partial / rolling
Samsung Internet —
Check latest
Internet Explorer —
Not supported
<selectedcontent> Limited

Bottom line: Use as progressive enhancement for customizable selects. Always keep a usable plain select.

Key Takeaways

  • Role: shows a clone of the selected option in the select button.
  • Placement: select > button:first-child > selectedcontent.
  • Style: target the clone separately from picker options.
  • Support: limited — enhance progressively.

One line: put <selectedcontent> in the first-child button of <select> to style the closed face of customizable selects.

Default CSS Settings

Supporting browsers render the clone inside the button. Authors often add rules such as:

default.css
/* Example author CSS — hide bulky media in the closed button */
selectedcontent img {
  display: none;
}

Exact UA defaults vary. Rely on progressive enhancement, not on a single engine’s look.

Frequently Asked Questions

selectedcontent lives inside the first-child button of a select and displays a clone of the currently selected option. It enables customizable selects where you style the closed button separately from the picker list.
No. It supports only the global HTML attributes. Behavior comes from its placement inside select > button.
As the (only) child of a button that is the first child of select. Options come after that button. Without this structure, browsers fall back to an implicit button you cannot target as selectedcontent.
The browser clones the selected option’s content into selectedcontent (via cloneNode). When the selection changes, the clone is replaced. Dynamic edits to an already-selected option after render may not sync automatically.
Content inside the select’s button — including selectedcontent — is inert by default. Users interact with the select control itself, not with focusable widgets inside the clone.
No. It has limited availability as part of customizable selects. Always provide a usable plain select fallback for unsupported browsers.

Next: shadow

Continue with the HTML shadow tag tutorial.

shadow tutorial →

CODETOFUN NEWS

Stay Ahead in Tech

Get the latest IT news, programming updates, and technology trends directly on your phone.

Your daily dose of tech, straight to your feed.

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful