CSS :has() Selector - Beyond Parent Selection for Advanced Element Targeting
Kevin Powell via YouTube
Live Online Classes in Design, Coding & AI — Small Classes, Free Retakes
Google, IBM & Meta Certificates — 40% Off for a Limited Time
Overview
Google, IBM & Meta Certificates — All 10,000+ Courses at 40% Off
One annual plan covers every course and certificate on Coursera. 40% off for a limited time.
Get Full Access
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