The :required pseudo-class matches any input, select, or textarea that has the HTML required attribute — fields that must be filled before the form can submit.
It marks the field as mandatory, not as valid. An empty required field still matches :required. Pair with :optional and :invalid for fuller form UX.
Baseline — widely available.
Supported across modern browsers since mid-2015. Always set the HTML required attribute for assistive tech — CSS alone is not enough for accessibility.
:required:invalid tightens the look when empty or bad.
Typing a valid email drops the invalid match (border softens).
Separates “must fill” from “value is wrong.”
Edge Cases & Pitfalls
Most confusion is mixing “required” with “valid.”
not valid
Empty required still matches
:required does not check the value. Use :valid / :invalid for filled vs empty.
a11y
Attribute + text, not color alone
Keep the HTML required attribute and a visible text or icon hint. Color-only borders fail WCAG intent for “required.”
select
Placeholder options
A required select often needs an empty first option (value="") so the browser can treat “no choice” as invalid until the user picks one.
checkbox
Required checkboxes
A required checkbox must be checked to submit. Style carefully so the box stays usable and labeled.
Compatibility
Browser Support
:required is a browser CSS pseudo-class. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
:required
Widely available across modern browsers since CSS / HTML5 form validation landed (MDN: mid-2015). Works with input, select, and textarea. Internet Explorer 10+ supports the selector with HTML5 forms.
98%Widely available
Google ChromeSupported
Full support
Mozilla FirefoxSupported
Full support
Apple SafariSupported
Full support
Microsoft EdgeSupported
Full support
OperaSupported
Full support
Samsung InternetSupported
Full support
Internet Explorer10+
With HTML5 forms
:requiredBaseline · Widely available
Bottom line: Safe for everyday form styling. Always set the required attribute in HTML. This is not a JavaScript runtime API.
Remember
Key Takeaways
Role: style controls that have the HTML required attribute.
Not validity: empty required fields still match :required.
Start simple:input:required { border-color: …; }.
A11y: attribute + text hint; pair with :optional / :invalid.
One line::required paints “must fill” — mark it in HTML, style it in CSS, don’t confuse it with valid.
Frequently Asked Questions
It matches input, select, or textarea elements that have the HTML required attribute — fields the user must complete before submit.
No. It only means the field is mandatory. An empty required field still matches :required. Use :valid / :invalid for filled vs empty validation styling.
:required matches controls with required. :optional matches controls without it. They are natural pairs for form styling.
Form controls that support the required attribute: many input types, select, and textarea. Buttons and non-form elements do not match.
No. It is a browser CSS pseudo-class. Node.js, Deno, and Bun do not apply it.