HTML selected Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The selected attribute is a boolean on <option>. When present, that option is initially selected in a <select> (or listed under <optgroup> / <datalist>).

Without multiple on the parent <select>, only one option may have selected. For checkboxes and radios, use checked instead.

Baseline · Widely available.

Not deprecated and not experimental. Stable across modern browsers since about July 2015.

Default state, not a live mirror.

After the user changes the list, the HTML attribute does not rewrite itself. Read the live choice with option.selected or select.value; the attribute maps to defaultSelected.

HTML Syntax

syntax.html
<option  selected>…</option>

Boolean form: write the name alone. selected="" or selected="selected" means the same thing.

Attribute Values

selected is boolean — presence turns the default selection on:

ValueDescriptionTry it
selected (present)Option is chosen when the page first loadsTry it
(absent)Option starts unselectedTry it
Placeholder pattern<option value="" selected> for “Please choose…”Try it
With multipleSeveral options may be selected at onceTry it

Live Preview

Pick which option gets the HTML selected attribute, then change the list and compare the default vs the live value.

Apply rebuilds the list from the attribute. Changing the demo select updates only the live value.

Select

HTML Examples

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

Example 1 — Preselect One Choice

Open the list with a default country already chosen.

HTML
<label for="country">Country:</label>
<select id="country" name="country">
  <option value="in" selected>India</option>
  <option value="us">United States</option>
  <option value="uk">United Kingdom</option>
</select>
Try It Yourself

How It Works

  1. Put selected on one <option> — here India.
  2. Single-select list — only that option should carry selected.
  3. Page load — the control shows India without a click.
  4. Form submit — unless the user changes it, country=in is sent.

Example 2 — “Please Choose…” Placeholder

Start with an empty value so the user must pick a real option when required is set.

HTML
<label for="pet">Choose a pet:</label>
<select id="pet" name="pet" required>
  <option value="" selected disabled>-- Please choose --</option>
  <option value="dog">Dog</option>
  <option value="cat">Cat</option>
  <option value="bird">Bird</option>
</select>
Try It Yourself

How It Works

  1. value="" — empty choice is not a real answer.
  2. selected — shows the prompt on first load.
  3. disabled — user cannot re-select the prompt after opening the list (common pattern).
  4. required — form validation fails until a real option is chosen.

Example 3 — Several Options Preselected

With multiple, more than one selected is allowed.

HTML
<label for="langs">Languages:</label>
<select id="langs" name="langs" multiple size="4">
  <option value="html" selected>HTML</option>
  <option value="css" selected>CSS</option>
  <option value="js">JavaScript</option>
  <option value="py">Python</option>
</select>
Try It Yourself

How It Works

  1. multiple — the select allows more than one choice.
  2. Two selected options — HTML and CSS start chosen.
  3. size — shows several rows so multi-select is obvious.
  4. Submit — typically sends repeated langs values for each chosen option.

Edge Cases & Pitfalls

Most bugs come from treating selected like a live state, or marking two options in a single-select.

single

Only one selected without multiple

MDN: if the parent <select> is not multiple, only one option may have selected. Extra marks are invalid / UA-resolved.

live

Attribute ≠ current choice after click

Use option.selected or select.value for the live value. The attribute is the default (defaultSelected).

checked

Not for checkbox / radio

Those controls use checked. selected belongs on <option>.

disabled

Disabled options stay unselectable

A disabled option (or one inside a disabled optgroup) cannot be chosen, even if it was previously selected.

a11y

Always label the select

Pair <select> with a visible <label> so the default choice has clear context.

Browser Support

selected is a boolean HTML attribute on <option>. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

selected

Widely available since about July 2015. Supported across modern browsers for select / option lists.

98% Global support (approx.)
Google Chrome All modern
Full support
Mozilla Firefox All modern
Full support
Apple Safari All modern
Full support
Microsoft Edge All modern
Full support
Opera All modern
Full support
Samsung Internet Modern
Full support
Internet Explorer Legacy support
Supported
selected Widely supported

Bottom line: Safe to use for default option choices. Remember the single-vs-multiple rule and read live state from properties.

Key Takeaways

  • Role: mark which <option> is initially selected.
  • Boolean: presence means selected — no special value needed.
  • multiple: required before more than one selected is valid.
  • JS: use .selected / select.value for the live choice.

One line: selected sets the default option — not a continuous sync of the user’s later choice.

Frequently Asked Questions

On an option element, selected is a boolean that marks the option as initially selected when the page loads (or when the form is reset to defaults).
The option element, inside select, optgroup, or datalist. It is not used on checkbox or radio inputs — those use checked.
Only if the parent select has the multiple attribute. Without multiple, only one option in that select may have selected.
Yes. Presence means selected. Write selected or selected="". In JavaScript use option.selected = true or false for the live state.
The HTML attribute sets the default. After the user changes the list, read the live choice with the .selected property (or select.value). The attribute maps to defaultSelected.
Use an option with value="" and selected (often also disabled and/or required on the select) so the empty choice is the initial display.

Next: shape

Define clickable shapes for image-map areas.

shape tutorial →

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.

8 people found this page helpful