HTML
html/required-select-placeholder
A required single-choice select starts with an empty placeholder option (value=""), so the required check can fail.
umiarkowanastatycznefe-forms
Dlaczego
A single-choice select always has a selected option; when the first real option is selected by default, required is already satisfied and the form submits whatever was preselected. People who did not notice the field send "Poland" or "Small" without choosing it, and the data is quietly wrong.
Poprawka
Make the first option a placeholder with an empty value: <option value="">Choose a country</option>. The HTML standard requires it on a required select with one visible row. Keep the label; the placeholder is not a label.
Przykłady
<!-- bad -->
<select id="country" name="country" required><option value="pl">Poland</option></select>
<!-- good -->
<select id="country" name="country" required><option value="">Choose a country</option><option value="pl">Poland</option></select>Źródła
Fakty
- Identyfikator
html/required-select-placeholder- Waga
- umiarkowana
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- Uczy jej skill
fe-formsNative forms and validation- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain html/required-select-placeholder