Challenge - 5 Problems
Group Selector Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ selector
intermediate2:00remaining
What elements are styled by this CSS rule?
Given the CSS rule
h1, p, .highlight { color: red; }, which elements will have red text?Attempts:
2 left
💡 Hint
Remember that group selectors apply the same style to all listed selectors.
✗ Incorrect
The group selector
h1, p, .highlight applies the style to all <h1> elements, all <p> elements, and any element with the class 'highlight'.📝 Syntax
intermediate2:00remaining
Identify the syntax error in this group selector
Which option shows the correct way to write a group selector for <h2>, <div>, and elements with class 'note'?
Attempts:
2 left
💡 Hint
Group selectors are separated by commas, not spaces or semicolons.
✗ Incorrect
Option D correctly uses commas to separate selectors. Option D selects .note inside div inside h2, which is different. Option D uses semicolons which is invalid syntax. Option D groups h2 div (descendant selector) and .note, which is not the same as grouping h2 and div separately.
❓ rendering
advanced2:00remaining
What color will the text be for <p class='highlight'> in this CSS?
Consider this CSS:
What color will the text inside <p class='highlight'> be?
p, .highlight { color: blue; }
.highlight { color: green; }What color will the text inside <p class='highlight'> be?
CSS
<p class='highlight'>Hello</p>Attempts:
2 left
💡 Hint
Later rules override earlier ones if selectors have the same specificity.
✗ Incorrect
The <p> and .highlight selectors both apply blue color, but the later .highlight rule sets color to green, overriding the earlier blue for elements with class 'highlight'.
❓ accessibility
advanced2:00remaining
How does grouping selectors affect accessibility styling?
If you want to increase font size for all headings (<h1>, <h2>, <h3>) and paragraphs with class 'important' for better readability, which CSS rule is best?
Attempts:
2 left
💡 Hint
Use commas to group selectors for applying the same style to multiple elements.
✗ Incorrect
Option A correctly groups selectors with commas to apply the font size to all headings and .important paragraphs. Option A selects .important inside h3 inside h2 inside h1, which is incorrect. Option A uses semicolons which is invalid. Option A uses adjacent sibling selectors which do not select all those elements.
🧠 Conceptual
expert2:00remaining
How many elements are affected by this CSS group selector?
Given the HTML:
And CSS:
How many elements will have purple text?
<h1>Title</h1>
<p>Paragraph</p>
<div class='note'>Note</div>
<span class='note'>Span Note</span>
And CSS:
h1, p, .note { color: purple; }How many elements will have purple text?
Attempts:
2 left
💡 Hint
Count all elements matching any selector in the group.
✗ Incorrect
The <h1> and <p> elements match their selectors. Both <div> and <span> have class 'note', so all four elements get purple text.