Skip to main content
InterviewHubPRO
Section Overview
Q13

Question 13 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

26%
CSS3 & Modern Layouts (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What are the modern CSS Pseudo-Classes: `:has()`, `:is()`, and `:where()`?

senior LevelCode ExampleSystem Design

In Simple Words:

  • :has() (The Parent Selector): Selects an element based on its descendants or following siblings:
    css
    /* Style card ONLY if it contains an image */
    .card:has(img) { grid-template-rows: 200px 1fr; }
    
    /* Style form label when its input is invalid! */
    label:has(+ input:invalid) { color: red; }
    
  • :is(): Simplifies long selector lists and takes the specificity of its most specific argument:
    css
    /* Replaces: header p, main p, footer p */
    :is(header, main, footer) p { line-height: 1.6; }
    
  • :where(): Identical to :is(), but always has 0 specificity (0,0,0)! Perfect for creating design system component libraries that developers can easily override.