Definition and Usage
The :required CSS pseudo-class represents any <input> element that has the required attribute set on it. This allows forms to easily indicate which fields must have valid data before the form can be submitted.
The :optional pseudo-class may be used to provide an appearance for optional form fields.
Examples
See :invalid for an example.
Compatibility
Desktop browsers
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 10.0 | 4.0 (2) | 10 | 10.0 | 5.0 |
Mobile browsers
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | NA | 4.0 (2) | Not supported | 10.0 | 5.0 |