The HTML selected attribute
Quick answer
The HTML selected attribute pre-selects an option in a <select> by default. It is used on the <option> element.
Overview
The selected attribute pre-selects a dropdown option. It is used on the <option> and <optgroup> elements.
It configures the choices in a drop-down — labeling option groups and pre-selecting a default. These sit inside a <select>.
Syntax
<option value="2" selected>Two</option>
Values
| Value |
|---|
| A boolean attribute — present or absent. |
Example
<select><option>One</option><option selected>Two</option></select>
Best practices
Frequently asked questions
What does the selected attribute do?
Pre-selects a dropdown option.
How do I group options in a drop-down?
Which elements use the selected attribute?
It is an element-specific attribute, used on the <option> and <optgroup> elements.