In this conference talk from late 2022, Eric Meyer presents the story of the CSS :has() pseudo class and how it came to be, dives into the details of how it works, and scratches the surface of the amazing powers it brings to developers.
Size: 11.95 MB
Language: en
Added: Mar 05, 2025
Slides: 43 pages
Slide Content
Eric Meyer
Developer Advocate, Igalia
Co-founder, An Event Apart CSS :has()
Unlimited Power
Eric Meyer
Developer Advocate, Igalia
Co-founder, An Event Apart CSS :has()
Unlimited Power
1996
CSS1
1998
CSS2
CSS1
CSS2
Simple selectors
Complex selectors
CSS1
CSS2
element, .class., #id
element, .class, #id,
[attr], a > b, a + b, …a > b
“The problem is that browsers cannot store all
of the information they need to know exactly
what to invalidate when something in the DOM
changes. They end up using a tainting model
that inevitably (in the worst case scenarios)
leads to over-invalidation.”shauninman.com/archive/2008/05/05/css_qualified_selectors#comment_3942
BROWSER VENDORS
vimeo.com/223432117 vimeo.com/286945944 Solving container queries today Contain Your Excitement
vimeo.com/223432117 vimeo.com/286945944 Solving container queries today Contain Your Excitement
html:has(.about-page) {
background: hsl(50deg,15%,93%);
}
html
head
body class="about-page"
header
…
main
…
footer
…
html
head
body
header
…
main class="about-page"
…
footer
…
body:has(nav.subnav) header.page {
margin-block-end: 0;
}
html
head
body
header class="page"
nav class="subnav"
…
main
…
footer
…
html
head
body
header class="page"
…
nav class="subnav"
…
main
…
footer
…
.hero:has(a[href]):has(.buy) {
padding: 1em;
background: #FAA;
}
header class="hero"
h1
a href="…"
div
span class="buy"
span class="sale"
header class="hero"
h1
a href="…" class="buy"
div
span class="sale"