Example A drop-down list with a preselected option: <select> <option>Volvo</option> <option se...
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 |