Questions
4 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.
04 / 25

What is the syntax for a combinator selector?

Difficulty: 2/10
combinator selectors, CSS specificity, selector performance

CSS Combinator Selector Syntax

A combinator selector in CSS consists of two or more simple selectors separated by a combinator symbol that defines their relationship.

Syntax Examples
  1. 1

    Descendant combinator (space): A B – selects all B elements that are descendants of A.

  2. 2

    Child combinator (>): A > B – selects all B elements that are direct children of A.

  3. 3

    Adjacent sibling combinator (+): A + B – selects the B element immediately following an A element.

  4. 4

    General sibling combinator (~): A ~ B – selects all B elements that are siblings following an A element.

Example: Using Combinator Syntax

Scenario Questions

0-2 years experience

  1. 1How would you write a selector to target only <li> elements that are direct children of a <ul>?
  2. 2If you need a style to apply to an <a> element that immediately follows an <h2>, what selector would you use?
  3. 3What elements are matched by the selector `div > p span`?

2-5 years experience

  1. 1A rule using `.card > .title` isn’t applying in some parts of the page. Walk me through how you’d debug the selector hierarchy.
  2. 2When refactoring a component you replace a descendant selector with a child selector. What trade‑offs are you considering regarding specificity and performance?
  3. 3A teammate reports that an adjacent sibling selector (`+`) is unexpectedly affecting elements added later via JavaScript. How would you investigate and fix it?

5-8 years experience

  1. 1In a large web app with thousands of CSS rules, many using combinators, how would you audit and optimise selector usage to reduce render‑time cost?
  2. 2Design a CSS architecture for a multi‑team product where only certain combinators are allowed in shared component libraries. What guidelines and tooling would you put in place?
  3. 3You need to support legacy browsers that don’t handle the general sibling selector (`~`). How would you rewrite the styles while preserving the visual hierarchy?

8+ years experience

  1. 1Your organization is migrating from a monolithic stylesheet to a CSS‑in‑JS solution. How would you handle existing combinator selectors to keep them maintainable across teams?
  2. 2When planning a long‑term UI framework, what considerations would you make about using combinator selectors versus utility‑first classes to balance developer ergonomics and performance?

Follow-up Questions

  • Why would you pick one combinator over another in that scenario?
  • How does the chosen combinator affect CSS specificity?
  • What impact does it have on browser rendering performance?
Share

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