pseudo-class
:required — CSS reference
Matches controls for which the applicable HTML required constraint is set. It does not say the value is invalid.
Formal Syntax & Structure
css syntaxcss
:requiredWorking Example
Example Snippetcss
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>Selector lab</title><style>:where(.sample) { color: rgb(32, 32, 32); }input:required { color: rgb(0, 96, 80); }</style></head><body><label>A <input id="a" class="sample" required value="ok"></label><label>B <input id="b" class="sample" value="ok"></label></body></html>