Question 1 of 10
Quiz
Back to lesson
Test your knowledge: CSS Selectors
Assess core CSS selector matching, namespace selection, logical pseudo-classes, relational matching, sibling filtering, and specificity-aware selector reasoning.
10 questions
~5 min
Beginner
Knowledge check
Test your knowledge: CSS Selectors
Assess core CSS selector matching, namespace selection, logical pseudo-classes, relational matching, sibling filtering, and specificity-aware selector reasoning.
- Stuck? Each question has an optional hint.
- Skip a hard question and review it before your results.
- Questions and answer options can shuffle between attempts.
You can retake this quiz whenever you like.
0:00
What does the bare selector
No punctuation in front of a word means the browser reads it as an element name.
A type selector matches elements by their element name, which is useful when the same presentation should apply to every element of that type. Punctuation-free selectors are element names, full stop.
Question 2 of 10
Which selector matches elements carrying
class="card"?
One symbol was set aside for classes, and it lives on the period key.
A class selector begins with a period followed by the class name, and it targets elements that share that class without requiring them to have the same element name.
Question 3 of 10
A page contains
<h2 id="headline">. Which selector matches it?
The number sign was reserved for ids.
An ID selector begins with a number sign followed by an identifier, and it matches the element whose id is that value. One page should hold one such element, which is exactly what makes it an id.
Question 4 of 10
Which statement about class and ID selectors is the one to build on?
Later in the path, ids get saved for JavaScript hooks and fragment targets. There is a reason for that economy.
Classes are reusable by design, so one class can dress a paragraph, a list item, and an aside at once. An ID matches one element per page, which is why styling with classes keeps a stylesheet flexible.
Question 5 of 10
A
.note class is written onto a
<p>, an
<li>, and an
<aside>. What does that let the author do?
The lesson calls this the point of classes: same presentation, different elements.
A class selector targets elements that share the class regardless of their element names, which is what lets a note look like a note wherever it appears. The class itself is supplied by the document, through the HTML class attribute.
Question 6 of 10
Which declaration makes the `svg|circle` selector meaningful for SVG elements?
The `svg` prefix must be bound in CSS with an `@namespace` rule before it is used in a namespace-qualified selector.
The CSS Namespaces specification defines `@namespace` as the mechanism for binding a CSS namespace prefix.
Review this lesson
Question 7 of 10
Which pseudo-class matches when any selector in its argument list matches?
Use the selector model from the lesson.
`:is()` is the matches-any pseudo-class.
Review this lesson
Question 8 of 10
What specificity does `:where(.note)` contribute?
Use the selector model from the lesson.
The `:where()` pseudo-class contributes zero specificity, including the selectors inside it.
Review this lesson
Question 9 of 10
What does `.card:has(> img)` match?
Use the selector model from the lesson.
`:has()` matches the candidate `.card` when its relative selector `> img` matches from that candidate as the anchor.
Review this lesson
Question 10 of 10
What does `of .featured` change in `:nth-child(2n of .featured)`?
Use the selector model from the lesson.
The `of S` clause filters which siblings participate in the index calculation.
Review this lesson
Quiz results
0/0
Review
-
What does the bare selectorHint used
pmatch? -
Which selector matches elements carryingHint used
class="card"? -
A page containsHint used
<h2 id="headline">. Which selector matches it? -
Which statement about class and ID selectors is the one to build on?Hint used
-
AHint used
.noteclass is written onto a<p>, an<li>, and an<aside>. What does that let the author do? -
Which declaration makes the `svg|circle` selector meaningful for SVG elements?Hint used
-
Which pseudo-class matches when any selector in its argument list matches?Hint used
-
What specificity does `:where(.note)` contribute?Hint used
-
What does `.card:has(> img)` match?Hint used
-
What does `of .featured` change in `:nth-child(2n of .featured)`?Hint used