Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML option selected attribute

HTML

HTML option Tag Reference HTML

Example

A drop-down list with a preselected option:

Try it »


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 preselected when the page loads.

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

**Tip:** You can also set the selected attribute via JavaScript after the page has loaded.


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


Syntax