Questions
5 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.
05 / 25

What is the descendant combinator in CSS?

Difficulty: 3/10
selector specificity, CSS performance, maintainability

Descendant Combinator in CSS

The descendant combinator in CSS is a space character ( ) that selects all elements that are descendants of a specified parent element, at any depth in the DOM tree.

Key Points
  1. 1

    Syntax: A B – selects all B elements inside A regardless of depth.

  2. 2

    It applies styles to nested elements without needing direct parent-child relationship.

  3. 3

    Useful for targeting elements deeply nested within a container without adding extra classes.

Example: Using Descendant Combinator

Scenario Questions

0-2 years experience

  1. 1You have a <nav> with <ul> and <li> elements. How would you write CSS to style only the <a> tags inside those <li> without affecting other links on the page?
  2. 2If you write `.card .title { color: red; }`, which elements will this rule apply to?
  3. 3What difference does a space make in `.button .active` versus `.button.active`?

2-5 years experience

  1. 1A teammate says the rule `.sidebar .menu-item` is also styling items in the header. Walk me through how you'd debug and fix the selector.
  2. 2You need to style all inputs inside a main form but not those inside a modal that also contains a form. How would you structure your selectors using descendant combinators?
  3. 3After adding a new component, page load slows down and you suspect CSS. Explain how deep descendant selectors could impact performance and what alternatives you might consider.

5-8 years experience

  1. 1Our design system mixes BEM naming with descendant selectors for theming. Discuss the trade‑offs of using deep descendant selectors in a large codebase regarding specificity, maintainability, and render performance.
  2. 2We’re refactoring a legacy stylesheet that heavily uses selectors like `.header .nav .item`. How would you rewrite these to improve modularity while preserving the visual look?
  3. 3Describe how the browser matches descendant selectors and the effect on paint time in a page with 10,000 DOM nodes. What strategies would you use to mitigate any performance hit?

8+ years experience

  1. 1Our organization is moving from monolithic CSS files to a component‑scoped CSS‑in‑JS approach. How would you decide whether to keep existing descendant combinator selectors or replace them, considering cross‑team ownership and future scalability?
  2. 2During a migration to a design‑token system, you need to ensure global descendant selectors don’t unintentionally override component styles. What architectural guidelines would you set to manage selector scope and avoid cascade conflicts?
  3. 3If you had to design a CSS architecture for a multi‑team product that must support legacy pages using deep descendant selectors and new pages using utility classes, how would you structure the stylesheet hierarchy and build process to keep them compatible yet isolated?

Follow-up Questions

  • How does the specificity of a descendant selector compare to a simple class selector?
  • What performance concerns arise with very deep descendant selectors on large pages?
  • When would you prefer the child combinator (>) over a descendant combinator?
Share

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.