When a <select> element is marked as required, the browser needs a way to determine whether the user has made a deliberate choice. The HTML specification requires that the first <option> element act as a placeholder — a non-selectable default that represents “no choice made.” For the browser’s constraint validation to work correctly, this placeholder option must have an empty value attribute (value=""), or it must have no text content at all.
This requirement only applies when all three conditions are met:
-
The <select> has a required attribute.
-
The <select> does not have a multiple attribute.
-
The <select> does not have a size attribute with a value greater than 1.
In this configuration, the <select> renders as a standard single-selection dropdown, and the first <option> with an empty value serves as the “please choose” prompt. If the user submits the form without changing the selection from this placeholder, the browser will block submission and display a validation message — just as it would for an empty required text input.
Why this matters
-
Form validation: Without a proper placeholder option, the browser may consider the first option as a valid selection, allowing the form to submit even when the user hasn’t actively chosen anything. This defeats the purpose of required.
-
Accessibility: Screen readers and assistive technologies rely on standard patterns. A placeholder option clearly communicates to all users that a selection is expected.
-
Standards compliance: The WHATWG HTML specification explicitly defines this constraint, and violating it produces a validation error.
How to fix it
-
Add a placeholder <option> as the first child of the <select>, with value="" and descriptive prompt text (e.g., “Choose an option”).
-
Alternatively, if you don’t want a visible placeholder, the first <option> can have no text content at all (<option value=""></option>), though this is less user-friendly.
-
Another approach is to add a size attribute equal to the number of options, or add the multiple attribute — but these change the visual presentation from a dropdown to a list box, so they’re only appropriate if that’s the desired UI.
Examples
❌ Incorrect: first option has a non-empty value
<select required>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
Here, “Small” is preselected and has a non-empty value. The browser treats it as a valid choice, so required validation never triggers — the form can be submitted without the user making an active decision.
❌ Incorrect: placeholder option has a non-empty value
<select required>
<option value="none">Choose a size</option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
The first option looks like a placeholder, but its value is "none" rather than empty. The validator flags this because the browser considers "none" a valid value.
✅ Correct: placeholder option with an empty value
<select required>
<option value="">Choose a size</option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
The first <option> has value="" and serves as a clear prompt. If the user doesn’t select a different option, form validation will prevent submission.
✅ Correct: placeholder option with no text content
<select required>
<option value=""></option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
This also satisfies the constraint, though it may appear as a blank entry in the dropdown. It can work in cases where a <label> already makes the expected action clear.
✅ Correct: using a size attribute to avoid the requirement
<select required size="3">
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
By adding size="3" (equal to the number of options), the <select> renders as a list box rather than a dropdown. The placeholder requirement no longer applies because no option is implicitly preselected — the user must click to choose. Note that this changes the visual appearance significantly.