Syntax - Tasty Web Development Treats

I can has() new CSS Selector?!

Jun 13, 2022
Discover the magic of the new CSS selectors: :has, :where, and :is, which streamline and enhance web development. Hear how :has allows styling of parent elements based on children, revolutionizing CSS practices. The conversation flows into using LogRocket for monitoring site functionality, complete with humorous parenting anecdotes. Plus, learn about navigating nested links and the browser support challenges, especially Safari's leading edge. Tune in for tips and a fresh take on coding with these innovative selectors!
Ask episode
AI Snips
Chapters
Transcript
Episode notes
ADVICE

The Has Pseudo-Class

  • Use the :has pseudo-class to style parent elements based on their children.
  • This lets you target elements like a paragraph containing a link.
ANECDOTE

Wes' Use Case for :has

  • Wes wanted to style WordPress blog posts differently if they contained a video.
  • He had to use server-side logic or JavaScript, but :has solves this.
INSIGHT

:has Simplifies Styling

  • The :has pseudo-class reduces work outside the browser.
  • It simplifies styling elements based on children, like blog posts with videos.
Get the Snipd Podcast app to discover more snips from this episode
Get the app