The selected attribute
The selected
attribute specifies the default selected item of the option
drop-down list select
.
Is an attribute without a value.
Example
Let's select the city Minsk by default. We'll do this using the selected
attribute:
<select>
<option>city1</option>
<option selected>city2</option>
<option>city3</option>
<option>city4</option>
</select>
:
Example . Multiple default values in multiselect
In a multiselect, more than one value can be selected by default:
<select multiple name="city[]">
<option>city1</option>
<option selected>city2</option>
<option>city3</option>
<option selected>city4</option>
</select>
:
See also
-
attribute
checked
,
which makes a checkbox or radio check mark