Latest web development tutorials

HTML option selected properties

Tag Reference HTML option HTML <option> tag

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>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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>


Tag Reference HTML option HTML <option> tag