HTML <option> Tag with the 'selected' Attribute
<select name="Food">
<option value ="apples">Apples</option>
<option value ="bananas">Bananas</option>
<option value ="oranges" selected>Oranges</option>
</select>
The above example demonstrates usage of the selected
attribute when using the <option>
element. In this example, the Oranges option has been selected.
The selected
attribute is used to select a given <option>
element as the default. This option will be selected upon the inital page load.
Boolean Attribute
The selected
attribute is a boolean attribute. If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace (i.e. either selected
or selected="selected"
).
Possible values:
- [Empty string]
- selected