Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

CSS :has() Selector - Beyond Parent Selection for Advanced Element Targeting

Kevin Powell via YouTube

Overview

Coursera Flash Sale
40% Off Coursera Plus for 3 Months!
Grab it
Explore the advanced capabilities of the CSS :has() pseudo-class selector beyond its basic parent selection functionality in this 12-minute tutorial. Learn how to leverage :has() for selecting elements that come after specific elements, targeting elements that precede other elements, and selecting all siblings of a given element. Discover techniques for counting child elements using :has() and master a bonus tip combining nth-child(of S) with :has() for more sophisticated element targeting. Gain practical knowledge of browser support considerations and see real-world examples of how this powerful CSS selector can enhance your styling capabilities for complex DOM relationships.

Syllabus

00:00 - Introduction
00:30 - basic usage
00:55 - select elements that come after
01:45 - select elements that come before another element
04:40 - select all the siblings of a given element
07:10 - counting how many children an element has
08:18 - bonus tip: nth-child of s along with :has

Taught by

Kevin Powell

Reviews

Start your review of CSS :has() Selector - Beyond Parent Selection for Advanced Element Targeting

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.