Code Examples
/* OLD WAY — repetitive */
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
color: inherit;
text-decoration: none;
}
/* MODERN WAY — :is() groups them */
:is(h1, h2, h3, h4, h5, h6) a {
color: inherit;
text-decoration: none;
}
/* Combine contexts ...
/* :where() has 0 specificity — easy to override */
:where(ul, ol) {
list-style: none;
padding: 0;
margin: 0;
}
/* This single-class rule easily overrides the :where() above */
.my-list {
list-style: disc; /* wins because .class > :whe...
/* Style a card differently if it contains an image */
.card:has(img) {
padding: 0; /* remove padding when image present */
}
/* Style a form when any input is invalid */
form:has(:invalid) {
border: 2px solid red;
}
/* Style a lab...