SelectList set selected value

HTML selected Attribute

HTML tag

Example

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

Choose a car:


Volvo
Saab
VW
Audi
Try it Yourself »

Definition and Usage

The selected attribute is a boolean attribute.

When present, it specifies that an option should be pre-selected when the page loads.

The pre-selected option will be displayed first in the drop-down list.

Tip: The selected attribute can also be set after the page loads, with a JavaScript.

Browser Support

Attribute selected Yes Yes Yes Yes Yes

Syntax

HTML tag

Video liên quan

Chủ Đề