Skip to main content
CSS-Tricks
  • Articles
  • Alamanac
  • Guides
  • Videos
  • Books
  • Newsletter
Search

Articles Tagged
parent selectors

5 Articles
{
,

}
Direct link to the article Meet `:has`, A Native CSS Parent Selector
:has parent selectors

Meet `:has`, A Native CSS Parent Selector

The reasons that are often cited that make container queries difficult or impossible is things like infinite loops—e.g. changing the width of an element, invalidating a container query, which changes the width again, which makes the container query take effect, …

Avatar of Chris Coyier
Chris Coyier on Jul 12, 2021
Direct link to the article Can I :has()
:has parent selectors

Can I :has()

I just joked that we’re basically getting everything we want in CSS super fast (mostly referring to container queries, my gosh, can you imagine they are actually coming?). Now we might actually get parent selectors?! As in .parent:has(.child) { …

Avatar of Chris Coyier
Chris Coyier on Jun 4, 2021
Direct link to the article A Use Case for a Parent Selector
parent selectors selectors

A Use Case for a Parent Selector

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 …

Avatar of Chris Coyier
Chris Coyier on Dec 31, 2019 (Updated on Mar 5, 2021)
Direct link to the article The `:focus-within` Pseudo Class
:focus-within parent selectors

The `:focus-within` Pseudo Class

Nice find by Ian Devlin:

The :focus-within pseudo class becomes active when an element itself has focus or if any of its descendants does.

Selecting a parent element based on children is lonnng awaited. The crown jewel of that …

Avatar of Chris Coyier
Chris Coyier on May 12, 2017
Direct link to the article Caching the Current Selector (&) in Sass
bem parent selectors scss

Caching the Current Selector (&) in Sass

The & character in Sass is unique in that it represents the current selector. It changes as you nest. Let’s say you are nested, but you want access to a selector back up the nesting a bit. The trick is …

Avatar of Chris Coyier
Chris Coyier on Feb 14, 2017

CSS-Tricks is powered by DigitalOcean.

Keep up to date on web dev

with our hand-crafted newsletter

DigitalOcean
  • About DO
  • Cloudways hosting
  • Legal stuff
  • Get free credit!
CSS-Tricks
  • Write for us!
  • Advertise with us
  • Contact us
Social
  • RSS Feeds
  • CodePen
  • Mastodon
  • X
Back to Top