Questions
10 of 25
1What are CSS combinators? How many types of CSS combinators are there?
2What is the purpose of using combinators in CSS?
3Can you list all the types of CSS combinators?
4What is the syntax for a combinator selector?
5What is the descendant combinator in CSS?
6How does the descendant combinator differ from a direct child combinator? Write an example of a descendant combinator selector. What is the impact of using multiple descendant selectors in a chain?
7How can overusing descendant combinators affect performance?
8How is the child combinator different from the descendant combinator?
9Write an example using the child combinator.
10Can the child combinator select a grandchild element? Why or why not?
11When would you prefer to use the child combinator instead of the descendant combinator?
12Can the adjacent sibling combinator select multiple elements? Write an example using the adjacent sibling combinator.
13How does the adjacent sibling combinator (+) differ from the general sibling combinator (~)? What is the general sibling combinator (~) used for?
14When would you use the general sibling combinator (~) instead of the adjacent sibling combinator (+)?
15Can the general sibling combinator (~) select elements that appear before the reference element?
16What happens if the sibling element doesn’t exist in the DOM? Can you combine multiple combinators in a single selector? Give an example.
17Can combinators be used together with pseudo-classes or pseudo-elements?
18What happens if you use a combinator between unrelated elements?
19How do combinators affect CSS inheritance and cascade?
20How would you select all <p> elements that are inside a <div> using combinators? How would you style only the direct child <li> elements inside a <ul>?
21How would you change the color of a paragraph that immediately follows a heading?
22How can you style all <span> elements that come after a specific <div>?
23Write a selector to target all <a> tags inside a <nav> but not inside a <footer>. How would you use combinators to create alternating styles between elements?
24What happens when combinators are used inside media queries? How can combinators improve maintainability in large CSS projects?
25Give a real-world example of using multiple combinators in a single rule.
10 / 25

Can the child combinator select a grandchild element? Why or why not?

Child Combinator and Grandchild Elements

The child combinator (>) cannot select a grandchild element because it only targets elements that are direct children of the specified parent. Elements nested deeper than the first level are not matched.

Key Points
  1. 1

    Syntax: A > B – selects only immediate children B of parent A.

  2. 2

    Grandchildren or deeper descendants require the descendant combinator (space) or additional selectors.

  3. 3

    Using the child combinator ensures precise styling for direct children without affecting nested elements.

Example: Child vs Grandchild
Difficulty: 3/10
Topics: child combinator, CSS selectors, DOM hierarchy

Scenario Questions

0-2 years experience
  1. 1

    You’re trying to style only the direct children of a nav menu, but your styles are also hitting the links inside dropdowns. What’s the issue, and how do you fix it using the child combinator?

  2. 2

    If you write .card > p, but the paragraph is inside a div inside the card, will it be styled? Why or why not?

2-5 years experience
  1. 1

    A teammate says their CSS rule .list > li { color: blue; } isn’t working, but the HTML looks right. What are three possible reasons you’d check, and how would you isolate the issue?

  2. 2

    We’re building a reusable card component where only top-level buttons should have padding, but nested buttons (like in a footer) shouldn’t. How would you use the child combinator to enforce this, and what edge cases might break it?

5-8 years experience
  1. 1

    In a dynamic CMS-driven UI, content authors can nest components arbitrarily. How would you design a CSS architecture using the child combinator to ensure styling predictability without over-constraining flexibility?

  2. 2

    You’re optimizing a legacy UI with 500+ CSS rules. You notice many descendant selectors (space) are causing unintended style leaks. How would you audit and refactor them using child combinators, and what risks would you mitigate?

8+ years experience
  1. 1

    We’re migrating from a legacy CSS framework that relies heavily on deep descendant selectors to a modern component-based system. How would you design a strategy to replace those with child combinators without breaking existing layouts across 20+ products?

  2. 2

    When designing a design system for a global company, how do you balance the precision of child combinators against the need for composability in nested third-party widgets? What tradeoffs do you document for engineers?

Follow-up Questions

  • What if you wanted to style all nested list items, not just direct ones?
  • How would you debug if a rule using > wasn’t applying as expected?
  • Can you think of a scenario where using > instead of a descendant selector improves performance?