:where
:where()
es una función que toma una lista de selectores como argumentos y selecciona cada uno de los elementos de la lista.
The :where() CSS pseudo-class function takes a selector list as its argument, and selects any element that can be selected by one of the selectors in that list.
Donde antes escribíamos:
main h2,
main h3 {
margin-block-start: 2rem;
margin-block-end: 1rem;
}
Ahora escribiremos:
:where(h2, h3) {
margin-block-start: 2rem;
margin-block-end: 1rem;
}
Las ventajas de usar :where()
:
- Generamos 0 specificidad.
- Si uno de los selectores de la lista no existe se ignora. Evitando que la declaración sea inválida,
Necesito especificidad
Entonces usa :is()
.
:is(h2, h3) {
margin-block-start: 2rem;
margin-block-end: 1rem;
}
Soporte