CSS wants to be a system - daverupert.com
CSS wants you to build a system with it. It wants styles to build up, not flatten down.
Truth!
I’m quite intrigued by the thinking behind this CSS selector of Heydon’s.
* + * {
margin-top: 1.5em;
}
I should try it out and see how it feels.
CSS wants you to build a system with it. It wants styles to build up, not flatten down.
Truth!
A terrific tour of just some of the fantastic ways you can use :has() in CSS.
The section on using it with sibling selectors blew my mind:
How often have you wanted to adjust the margins on a headline based on the element following it? Now it’s easy. This code allows us to select any h2 with a p immediately after it.
h2:has(+ p) { margin-bottom: 0; }Amazing.
Well, the clever CSS techniques just keep on comin’ from Trys—I’m learning so much from him!
A really interesting proposal from Lea that would allow CSS authors to make full use of selectors but without increasing specificity. Great thoughts in the comments too.
Had you heard of these bits of CSS? Me too/neither!