Combinator and grouping selectors
A space combinator like 'div p' targets every p inside a div. Combinators (space, >, +, ~) select by relationship; a comma groups selectors so several share one rule.
Understanding Combinator and grouping selectors in HTML & CSS
What it does: The > child combinator restricts the match to direct children, which 'ul > li' demonstrates. The + adjacent sibling combinator selects the element right after its sibling, as 'h2 + p' shows. A comma groups selectors so they share one set of declarations. > selects direct children only; a space selects descendants at any depth. ~ is the general sibling combinator, matching all later siblings, not just the next one. 'div p' uses a space, the descendant combinator, to match every <p> inside a <div>. The commas group the three selectors so the same declarations apply to all of them.
Common mistakes: The comma groups selectors, so this targets every <article> and every <p> separately. To target paragraphs inside an article, use a space (descendant combinator): 'article p'. Line 1 ends with a period, which starts a class selector and breaks the group. Each grouped selector is separated by a comma: 'h2,'.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 31–41) and word search (Modules 21–41).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
div pFill in the Blanks
Spot the Error
Student with a class code? Join your class →