Select the Previous Sibling
.element:hover:has(+ & + *) { /* styles */ }
A really handy recipe from Chris that is a perfect use case for the :has()
selector. Say we have a series of card components in a row. And when one card …
.element:hover:has(+ & + *) { /* styles */ }
A really handy recipe from Chris that is a perfect use case for the :has()
selector. Say we have a series of card components in a row. And when one card …
A few sirens went off a couple of weeks ago when the CSS Working Group (CSSWG) resolved to add an if()
conditional to the CSS Values Module Level 5 specification. It was Lea Verou’s X post that same day that …
/* Case sensitive */
a[href*='css-tricks' s] {}
/* Case insensitive */
a[href*='css-tricks' i] {}
Adding an s
makes the selector case-sensitive and i
makes it case-insensitive.
I didn’t realize the support for @supports
determining selector support was so good! I usually think of @supports
as a way to test for property: value
pair support. But with the selector()
function, we can test for selector support …
I think this is good advice from Silvestar Bistrović:
An enabling selector is what I call a selector that does a job without disabling the particular rule.
The classic example is applying margin
to everything, only to have to remove …
This is a neat interactive page by Ville V. Vanninen to reference the names of things in the CSS syntax. I feel like the easy ones to remember are “selector,” “property,” and “value,” but even as a person who writes …
Having a “parent selector” in CSS is mentioned regularly as something CSS could really use. I feel like I’ve had that thought plenty of times myself, but then when I ask my brain for a use case, I find it …
You can have multiple classes on an HTML element:
<div class="module p-2"></div>
Nothing incorrect or invalid there at all. It has two classes. In CSS, both of these will apply:
.module { }
.p-2 { }
const div = document.querySelector("div");
…