HTML selected Attribute

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 3 Examples
Forms & Select

Introduction

The selected attribute is a boolean attribute on <option> elements. It marks an option as pre-selected when the page loads inside a <select> dropdown. Use it to provide a sensible default—such as a user’s country, a common plan, or a placeholder choice that still has a real value.

What You’ll Learn

01

<option>

Where it applies.

02

Boolean

Presence = true.

03

Default value

On page load.

04

multiple

Multi-select lists.

05

JavaScript

.value / .selected

06

Accessibility

Ethical defaults.

Purpose of selected

The primary purpose of the selected attribute is to specify the initially selected option within a <select> control. When the form renders, that option appears in the closed dropdown and its value is submitted if the user does not change the selection.

This improves usability when one choice is clearly the most common, when restoring a previously saved preference, or when guiding users toward a recommended default without removing other choices.

💡
On <option>, not <select>

Put selected on the <option> you want pre-selected. The parent <select> does not take a selected attribute.

📝 Syntax

Add the boolean selected attribute to one <option> inside a <select>:

selected.html
<select name="plan">
  <option value="free">Free</option>
  <option value="pro" selected>Pro</option>
  <option value="team">Team</option>
</select>

Syntax Rules

  • Valid on <option> elements inside <select> (including within <optgroup>).
  • Boolean attribute—write selected, selected="", or selected="selected" (XHTML style).
  • In a single-select <select>, only one option should have selected.
  • If no option has selected, the first option is selected by default in most browsers.
  • With <select multiple>, multiple options may have selected.
  • Disabled options (disabled on <option>) cannot be selected.

💎 Values

The selected attribute is a boolean attribute—it has no meaningful string value. Its presence alone marks the option as selected:

  • <option selected> — Standard HTML5 boolean form.
  • <option selected=""> — Empty string value (equivalent).
  • <option selected="selected"> — XHTML-style; still valid.
  • Absence of selected — Option is not pre-selected (unless chosen by browser default rules).
selected-multiple.html
<!-- Multiple selections with select multiple -->
<select name="toppings" multiple size="4">
  <option value="cheese" selected>Cheese</option>
  <option value="pepperoni" selected>Pepperoni</option>
  <option value="mushroom">Mushroom</option>
</select>

⚡ Quick Reference

Use CaseMarkupNotes
Default dropdown option<option value="x" selected>Single-select
Boolean formselected (no value needed)HTML5 standard
Multi-select defaultsMultiple selected optionsRequires select multiple
JS by valueselect.value = "saab"Common pattern
JS on optionoption.selected = trueDirect property
Applicable element<option>Inside <select>

Applicable Elements

ElementSupported?Notes
<option>YesPrimary and only standard use
<select>NoPut selected on child options
<optgroup>NoOptions inside groups can have selected
<input>NoUse checked for radio/checkbox

selected vs checked vs select.value

Featureselectedcheckedselect.value (JS)
Used on<option>input type=checkbox/radio<select> element
PurposePre-select dropdown optionPre-check inputChange selection at runtime
Boolean?YesYesN/A (property assignment)
Multiple at onceOnly with multipleRadios: one per groupSingle value (or array-like for multiple)

Examples Gallery

Basic boolean selected, a form with a default car choice, and dynamic selection with JavaScript.

👀 Live Preview

Dropdown with Pro pre-selected via selected:

Pro loads selected because its <option> has the selected attribute.

Example — Basic Boolean selected

The simplest use: mark one option as the default:

selected.html
<select>
  <option value="option1" selected>Option 1</option>
  <option value="option2">Option 2</option>
  <option value="option3">Option 3</option>
</select>
Try It Yourself

How It Works

The presence of selected on the first <option> makes it the default choice. Users can still open the list and pick another option.

Example — Form with Default Selection

Pre-select Mercedes in a car chooser form:

car-form.html
<form>
  <label for="car">Select your car:</label>
  <select id="car" name="car">
    <option value="volvo">Volvo</option>
    <option value="saab">Saab</option>
    <option value="mercedes" selected>Mercedes</option>
    <option value="audi">Audi</option>
  </select>
  <input type="submit" value="Submit">
</form>
Try It Yourself

How It Works

When the form loads, Mercedes appears in the closed dropdown. On submit, the browser sends the selected option’s value attribute.

Dynamic Values with JavaScript

Change the selected option based on conditions or user data:

dynamic-selected.html
<select id="dynamicSelect">
  <option value="volvo">Volvo</option>
  <option value="saab">Saab</option>
  <option value="mercedes">Mercedes</option>
</select>

<script>
  var conditionMet = true;
  if (conditionMet) {
    document.getElementById("dynamicSelect").value = "saab";
  }
</script>
Try It Yourself

How It Works

Setting select.value selects the matching option and updates the selected property on options. You can also set option.selected = true directly when building lists dynamically.

♿ Accessibility

  • Pair with labels — Use <label for="selectId"> so users know what the dropdown controls.
  • Choose ethical defaults — Pre-selecting expensive or opt-in options can confuse users; defaults should be neutral or clearly beneficial.
  • Avoid placeholder-only defaults — If no valid choice exists yet, use a disabled placeholder option instead of a misleading pre-selection.
  • Announce changes — When JavaScript changes selection, ensure related UI updates are visible; don’t rely on color alone.
  • Keyboard accessible — Native <select> supports arrow keys and type-ahead; custom widgets need full ARIA support.

🧠 How selected Works

1

Author marks option selected

Boolean on one or more options.

Markup
2

Browser renders default

Dropdown shows that choice.

UX
3

Form submits value

Unless user picks another option.

Forms
=

Smarter defaults

Users start with a sensible choice.

Browser Support

The selected attribute is supported in all modern browsers on <option> elements inside <select> controls.

HTML5 · Fully supported

Universal dropdown preselection

All major browsers honor selected on options for single and multiple select lists.

99% Browser support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
selected attribute 99% supported

Bottom line: Use selected confidently for default dropdown options in all modern projects.

💡 Best Practices

✅ Do

  • Pre-select a common or recommended default when it helps users
  • Use one selected option in single-select dropdowns
  • Match value attributes to what your server expects
  • Use select.value in JavaScript for dynamic updates
  • Label every <select> with <label>

❌ Don’t

  • Put selected on the <select> element itself
  • Mark multiple options selected without multiple
  • Pre-select paid upgrades users did not choose
  • Rely on the first option as an accidental default when none should be chosen
  • Confuse selected with checked on checkboxes

Conclusion

The selected attribute is a valuable tool for defining default selections in HTML dropdowns. By placing it on the right <option>, you guide users toward common choices and reduce extra clicks.

Use it thoughtfully for accessibility and ethics, combine it with proper labels and value attributes, and update selections dynamically with select.value or option.selected when your UI needs to react to user data.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about selected

Bookmark these before your next dropdown form.

5
Core concepts
02

Boolean

Presence = true

Syntax
📄 03

Default

On page load

Purpose
⚙️ 04

select.value

JS updates

Dynamic
05

Ethical UX

Fair defaults

A11y

❓ Frequently Asked Questions

It pre-selects an <option> inside a <select> dropdown when the page loads.
<option> elements only. Put it on the option you want selected, not on <select>.
Yes. Write selected alone or selected="". No value like selected="true" is needed.
Yes, but only when the parent <select> has the multiple attribute. Otherwise use one selected option.
Set selectElement.value = "optionValue" or optionElement.selected = true on the target option.
Yes in all modern browsers on <option> elements inside <select>.

Build better dropdown forms

Practice the selected attribute with default options in the Try It editor.

Try car form example →

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.

5 people found this page helpful