Selectors CSS Interview Questions
13 curated selectors interview questions for CSS — with short answers, detailed explanations, and interview tips. Ideal for Fresh through Tech Lead prep.
What is the difference between .a .b and .a.b?
Explain child, sibling, and adjacent sibling combinators.
When do you use :is() vs :where()?
What does :has() enable?
Attribute selectors — equals vs contains vs prefix?
Pseudo-classes vs pseudo-elements?
Why prefer :focus-visible over :focus for outlines?
How do specificity traps happen with IDs in selectors?
What are structural pseudo-classes like nth-child useful for?
Selector performance myths — what matters today?
How do you style a form control only when invalid after interaction?
Explain :not() limitations and nesting.
Establish selector conventions for a large codebase.