HTML option selected properties
Examples
With pre-selected options drop-down list:
<select>
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="vw">VW</option>
<option value="audi" selected>Audi</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"
Browser Support
All major browsers support the selected property.
Definition and Usage
selected attribute is a Boolean attribute.
selected attribute specifies when the page loads the pre-selected option.
Pre-selected options are displayed in the drop-down list foremost position.
Tip: You can also set through JavaScript after the page loads the selected property.
Differences between HTML 4.01 and HTML5
no.
Differences between HTML and XHTML
In XHTML, prohibit attribute minimization, selected property must be defined as <option selected = "selected">.
grammar
<option selected>
HTML <option> tag