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

How do combinators affect CSS inheritance and cascade?

Difficulty: 6/10
combinators, inheritance, cascade

Combinators and Their Effect on Inheritance and Cascade

CSS combinators do not change the rules of inheritance or the cascade themselves. They control which elements a selector matches based on DOM relationships, but once an element is matched, normal inheritance and cascade rules apply.

Key Points
  1. 1

    Combinators (descendant, child, adjacent sibling, general sibling) define which elements the style applies to, not how properties are inherited.

  2. 2

    Matched elements receive the specified styles, and these styles participate in the normal cascade with specificity, importance (!important), and order of appearance.

  3. 3

    Properties that naturally inherit (like color or font-family) still propagate to children unless overridden, regardless of combinators used.

  4. 4

    Using complex combinators can increase specificity, potentially overriding other rules in the cascade.

Example: Combinators and Cascade

Scenario Questions

0-2 years experience

  1. 1You need to style all <button> elements inside a <nav> but not those outside. How would you write the selector using a combinator, and what effect does it have on inheritance of font properties?
  2. 2If you apply `color: red` to a parent div and then use a child combinator selector to set `color: blue` on its direct children, what will the final color be for a nested span inside those children?

2-5 years experience

  1. 1A teammate reports that a `margin` set on a `.card` component is not being inherited by a `.card-header` that is a sibling. They used a general sibling combinator in the CSS. Walk me through why the margin isn’t inherited and how the combinator influences the cascade.
  2. 2During a feature rollout, a new CSS rule using the adjacent sibling combinator unexpectedly overrides a global typography rule. How would you debug the cascade to determine which rule wins, and what role the combinator plays?

5-8 years experience

  1. 1Our design system uses deep nesting with child and descendant combinators to enforce theme colors. At scale, this is causing specificity wars and unexpected inheritance. How would you refactor the selectors to maintain theme consistency while reducing cascade complexity?
  2. 2We need to support a theming switch that changes background colors via CSS variables. Some components use complex combinator chains that prevent the variable from being inherited. Explain how you would audit and redesign those selectors to ensure proper inheritance and cascade behavior.

8+ years experience

  1. 1We are migrating a legacy monolithic CSS codebase to a modular CSS-in-JS solution. The old code heavily relies on combinator selectors for layout. What architectural considerations would you make to replace those combinators while preserving inheritance semantics and minimizing cascade side effects across teams?
  2. 2Across multiple product teams, inconsistent use of combinators has led to CSS bloat and maintenance headaches. Propose a company-wide guideline or tooling strategy to standardize combinator usage, balancing developer ergonomics, performance, and cascade predictability.

Follow-up Questions

  • Can you show a concrete selector where changing a descendant to a child combinator changes the computed style?
  • How does selector specificity interact with combinators when two rules conflict?
  • What strategies do you use to keep combinator usage from bloating specificity in a large codebase?
Share

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