Latest

recent

HTML Option selected attribute

Example

A drop-down list with a preselected option:
<select>
  <option>Volvo</option>
  <option selected="selected">Saab</option>
  <option>Mercedes</option>
  <option>Audi</option>
</select>

Definition and Usage

The selected attribute specifies that an option should be preselected when the page loads.
The selected option will be displayed first in the drop-down list.
The selected attribute can also be set after the page load, with a JavaScript.

Browser Support

The selected attribute is supported in all major browsers.

Syntax

<option selected="value">

Attribute Values

Value Description
selected Selects an option
HTML Option selected attribute Reviewed by 1000sourcecodes on 21:42 Rating: 5
Powered by Blogger.