CSS :requiredSelectors
Complete CSS Selector Reference Manual
Example
If the input element has the "required" attribute set, set it to yellow:
input:required
{
background-color: yellow;
}
{
background-color: yellow;
}
Try it Yourself »
Definition and use
The :required selector sets the specified style when a form element is a required field.
Form elements can use the required attribute to set required fields.
Note::required selector applies only to form elements: input, select, and textarea.
Browser Support
The numbers in the table indicate the first browser version number that supports the attribute.
| Selectors | |||||
|---|---|---|---|---|---|
| :required | 10.0 | 10.0 | 4.0 | 5.0 | 10.0 |
CSS Syntax
:required
{
CSS Declaration;
}
{
CSS Declaration;
}
Related Pages
CSS selectors:optional
other extensions