HTML <option> selectedAttributes

HTML option 标签参考手册HTML <option> Tag

Examples

A drop-down list with a pre-selected option:

<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</option>
</select>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the selected attribute.


Definition and Usage

The selected attribute is a boolean attribute.

The selected attribute specifies that the option is pre-selected when the page loads.

The pre-selected option is displayed at the top of the drop-down list.

Tip:You can also set the selected attribute through JavaScript after the page loads.


Differences Between HTML 4.01 and HTML5

None.


Differences Between HTML and XHTML

In XHTML, attribute minimization is forbidden, and the selected attribute must be defined as <option selected="selected">.


Syntax

<option selected>


HTML option 标签参考手册HTML <option> Tag Other Extensions