You’re reading the English version of this content since no translation exists yet for this locale. Help us translate this article!
La pseudo-class CSS :required
representa qulasevol element <input>
, <select>
o <textarea>
que té l'atribut required
establert en ell.
/* Selecciona qualsevol <input> requerit */ input:required { border: 1px dashed red; }
Aquesta pseudo-class és útil per ressaltar els camps que han de tenir dades vàlides abans de poder enviar un formulari.
Nota: La classe pseudo-class :optional
selecciona camps de formulari opcionals.
Sintaxi
:required
Exemples
Veure :invalid
com exemple.
Especificacions
Especificació | Estat | Comentari |
---|---|---|
HTML Living Standard The definition of ':required' in that specification. |
Living Standard | Sense canvis. |
HTML5 The definition of ':required' in that specification. |
Recommendation | Defineix la semàntica respecte a HTML i la validació de restriccions. |
Selectors Level 4 The definition of ':required' in that specification. |
Working Draft | Sense canvis. |
CSS Basic User Interface Module Level 3 The definition of ':required' in that specification. |
Recommendation | Defineix la pseudo-classe, però no la semàntica associada. |
Navegadors compatibles
We're converting our compatibility data into a machine-readable JSON format.
This compatibility table still uses the old format,
because we haven't yet converted the data it contains.
Find out how you can help!
Descripció | Chrome | Edge | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|---|
Suport bàsic | 10.0 | (Yes) | 4.0 (2) | 10 | 10.0 | 5.0 |
Descripció | Android | Edge | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|---|
Suport bàsic | 4.4.4 | (Yes) | 4.0 (2) | No support | 10.0 | 5.0 |
Vegeu també
- Altres pseudo-classes relacionades amb la validació:
:optional
,:invalid
,:valid
- Validació de dades del formulari