Ensure that you provide a value=""
for the initial option. Omitting the value=""
attribute will result in the option's value being implicitly set to its text content, satisfying the required
condition.
Example:
select:invalid { color: red; }
<select required>
<option disabled value="" selected>- please choose -</option>
<option value="1">A</option>
<option value="2">B</option>
</select>
The CSS above will render the select element and all options in red until a selection is made.
If you prefer the options to always appear black, you can modify the CSS as follows:
select:invalid { color: red; }
select option { color: black; }
<select required>
<option disabled value="" selected>- please choose -</option>
<option value="1">A</option>
<option value="2">B</option>
</select>