CSS Quiz
Thirty questions covering the whole course. Choose an answer for each, then press Check answers at the bottom to see your score and an explanation for every question.
1. Which way of adding CSS is best for a multi-page website?
One cached file styles every page and keeps content and presentation separate (lesson 02).
2. What does nav a select?
A space is the descendant combinator (lesson 04).
3. What is the specificity of ul li.item:hover?
One class plus one pseudo-class gives 2 in the middle column; two type selectors give 2 in the last (lesson 07).
4. Two rules with equal specificity set the same property. Which wins?
When everything else is equal, source order decides (lesson 07).
5. Which of these properties is inherited by default?
Text-related properties inherit; box-related ones don't (lesson 08).
6. A user sets their browser's default font size to 20px. Which unit respects that?
rem is relative to the root font size, which follows the user's setting (lesson 09).
7. What does clamp(1rem, 2.5vw, 2rem) return on a very wide screen?
The preferred value is capped at the maximum (lesson 14).
8. Where can a custom property declared on :root be used?
Custom properties inherit, so values on the root reach every element (lesson 13).
9. With box-sizing: content-box, a box has width: 200px; padding: 20px; border: 5px solid. How wide is it on screen?
200 + 2×20 + 2×5 = 250. With border-box it would be 200px (lesson 17).
10. Two paragraphs have margin-bottom: 30px and margin-top: 20px. How much space is between them?
Vertical margins collapse to the larger one (lesson 15).
11. Which font-display value shows fallback text immediately and swaps in the web font when it loads?
swap avoids invisible text while the font downloads (lesson 20).
12. What does display: none do that visibility: hidden doesn't?
visibility: hidden keeps the element's space (lesson 23).
13. An element with position: absolute is positioned relative to what?
If no ancestor is positioned, the initial containing block is used (lesson 24).
14. Why might z-index: 9999 fail to put an element on top?
z-index values only compete within the same stacking context (lesson 25).
15. In a Flexbox row, which property aligns items vertically?
justify-content works on the main axis; align-items on the cross axis (lesson 27).
16. What does flex: 1 on every item in a row do?
Grow 1, shrink 1, basis 0 — so all items get an equal share (lesson 28).
17. What does grid-template-columns: 200px 1fr create?
fr distributes the free space left after fixed tracks (lesson 29).
18. Which declaration makes a grid item span from the first column line to the last?
Negative line numbers count from the end (lesson 30).
19. What is a "mobile-first" stylesheet?
Small-screen styles are simpler, so building upwards keeps the CSS lean (lesson 32).
20. How do container queries differ from media queries?
A component can adapt to wherever it is placed (lesson 33).
21. What does margin-inline-start map to in a right-to-left language?
Logical properties follow the writing direction (lesson 34).
22. Which properties are cheapest to animate?
They avoid layout and paint work, so the browser can animate them smoothly (lesson 37).
23. What must a transition have to work?
Transitions animate between two states; keyframe animations can run on their own (lessons 37–38).
24. What does object-fit: cover do to an image?
contain would show the whole image with letterboxing (lesson 41).
25. What does .card:has(img) select?
:has() selects an element based on its contents (lesson 43).
26. What is the specificity of :where(#nav .link)?
:where() always contributes zero, which makes it ideal for defaults (lesson 43).
27. In native CSS nesting, what does &.active inside .tab { } mean?
& is replaced by the parent selector with no space (lesson 44).
28. With @layer base, utilities;, a #id rule in base and a .class rule in utilities both set color. Which wins?
Layer order is checked before specificity (lesson 45).
29. What does light-dark(white, black) need in order to switch values?
The function follows the used colour scheme (lesson 46).
30. What is the minimum WCAG contrast ratio for normal-sized body text?
3:1 applies to large text and interface components (lesson 48).
Want more practice? Try the exercises, or revisit any lesson from the course home.