👀 Live Preview
Dropdown with Pro pre-selected via selected:
Pro loads selected because its <option> has the selected attribute.

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.
Where it applies.
Presence = true.
On page load.
Multi-select lists.
.value / .selected
Ethical defaults.
selectedThe 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.
Put selected on the <option> you want pre-selected. The parent <select> does not take a selected attribute.
Add the boolean selected attribute to one <option> inside a <select>:
<select name="plan">
<option value="free">Free</option>
<option value="pro" selected>Pro</option>
<option value="team">Team</option>
</select><option> elements inside <select> (including within <optgroup>).selected, selected="", or selected="selected" (XHTML style).<select>, only one option should have selected.selected, the first option is selected by default in most browsers.<select multiple>, multiple options may have selected.disabled on <option>) cannot be selected.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.selected — Option is not pre-selected (unless chosen by browser default rules).<!-- 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>| Use Case | Markup | Notes |
|---|---|---|
| Default dropdown option | <option value="x" selected> | Single-select |
| Boolean form | selected (no value needed) | HTML5 standard |
| Multi-select defaults | Multiple selected options | Requires select multiple |
| JS by value | select.value = "saab" | Common pattern |
| JS on option | option.selected = true | Direct property |
| Applicable element | <option> | Inside <select> |
| Element | Supported? | Notes |
|---|---|---|
<option> | Yes | Primary and only standard use |
<select> | No | Put selected on child options |
<optgroup> | No | Options inside groups can have selected |
<input> | No | Use checked for radio/checkbox |
selected vs checked vs select.value| Feature | selected | checked | select.value (JS) |
|---|---|---|---|
| Used on | <option> | input type=checkbox/radio | <select> element |
| Purpose | Pre-select dropdown option | Pre-check input | Change selection at runtime |
| Boolean? | Yes | Yes | N/A (property assignment) |
| Multiple at once | Only with multiple | Radios: one per group | Single value (or array-like for multiple) |
Basic boolean selected, a form with a default car choice, and dynamic selection with JavaScript.
Dropdown with Pro pre-selected via selected:
Pro loads selected because its <option> has the selected attribute.
The simplest use: mark one option as the default:
<select>
<option value="option1" selected>Option 1</option>
<option value="option2">Option 2</option>
<option value="option3">Option 3</option>
</select>The presence of selected on the first <option> makes it the default choice. Users can still open the list and pick another option.
Pre-select Mercedes in a car chooser form:
<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>When the form loads, Mercedes appears in the closed dropdown. On submit, the browser sends the selected option’s value attribute.
Change the selected option based on conditions or user data:
<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>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.
<label for="selectId"> so users know what the dropdown controls.<select> supports arrow keys and type-ahead; custom widgets need full ARIA support.Boolean on one or more options.
Dropdown shows that choice.
Unless user picks another option.
Users start with a sensible choice.
The selected attribute is supported in all modern browsers on <option> elements inside <select> controls.
All major browsers honor selected on options for single and multiple select lists.
Bottom line: Use selected confidently for default dropdown options in all modern projects.
selected option in single-select dropdownsvalue attributes to what your server expectsselect.value in JavaScript for dynamic updates<select> with <label>selected on the <select> element itselfselected without multipleselected with checked on checkboxesThe 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.
selectedBookmark these before your next dropdown form.
Not on select
ScopePresence = true
SyntaxOn page load
PurposeJS updates
DynamicFair defaults
A11y<option> inside a <select> dropdown when the page loads.<option> elements only. Put it on the option you want selected, not on <select>.selected alone or selected="". No value like selected="true" is needed.<select> has the multiple attribute. Otherwise use one selected option.selectElement.value = "optionValue" or optionElement.selected = true on the target option.<option> elements inside <select>.Practice the selected attribute with default options in the Try It editor.
5 people found this page helpful