HTML selected Attribute
Example
<label for="lang">Choose a language:</label>
<select id="lang">
<option value="HTML">HTML</option>
<option value="CSS" selected>CSS</option>
<option value="JavaScript">JavaScript</option>
</select>
Meaning
The selected attribute specifies that the associated item is the default selection.
If this attribute is not included, the first item in the selection list is the default.
Note: It should occur in only one entry. Under XHTML, the value of the selected attribute must be set to selected(selected="selected").
Standard Syntax
HTML: <element selected>
XHTML: <element selected="selected">
Browser Support
Status
Applies to:
The selected attribute can be used on the following element:
Attribute Values
Value | Description |
---|---|
selected | It's optional but mandatory in XHTML. |