Grouping selectors
Ordinarily, when we want to share a bunch of properties across a number of things, we just comma-separate the selectors into a list:
.thing1,
[data-thing],
#thing {
/* styles */
}
That works fine for a few things. All those comma-separated selectors get the same styles applied, but it can start to become unwieldy and repetitive in more complicated scenarios:
.blog-post > h1,
.blog-post > h2,
.blog-post > h3,
.blog-post > h4,
.blog-post > ul,
.blog-post > ul li,
.blog-post > p,
.blog-post > a {
/* shared styles */
}
The other downside is that a single mistake in that group renders the whole list invalid:
.blog-post > h1,
.blog-post > h2,
.blog-post > h3,
.blog-post > h4,
.blog-post > ul,
.blog-post > ul < li,
.blog-post > p,
.blog-post > a {
/* shared styles */
}
That accidental “less than” symbol will mean this rule won’t apply any styles to any of the...