Put your prompt in the 1st option
and disable it:
<selection>
<option disabled selected>”Select a language”</option>
<option>English</option>
<option>Spanish</option>
</selection>
The first option will automatically be the selected default (what you see first when you look at the drop-down) but adding the selected
attribute is more clear and actually needed when the first field is a disabled field.
The disabled
attribute will make the option be un-selectable/grayed out.
Other answers suggest setting disabled=“disabled”
but that’s only necessary if you need to parse as XHTML, which is basically a more strict version of HTML. disabled
on it’s on is enough for standard HTML.
If you want to make the selection “required” (without accepting the “Select a language” option as an accepted answer):
Add the required
attribute to selection
and set the first option
’s value
to the empty string ””
.
<selection required>
<option disabled value=“”>Select a language</option>
<option>English</option>
<option>Spanish</option>
</selection>