TetSharing

CSS final quiz

One question from each of the 12 chapters. Pick an answer for each, then press Check answers. Each explanation links back to the chapter it comes from, so you know exactly what to reread.

12 questions

1. Which way of adding CSS lets every page of a site share one cached file?

<link rel="stylesheet" href="..."> loads one file that the browser caches across pages. (Chapter 1: Get started)

2. What does .card.featured match?

Without a space, both classes must be on the same element. (Chapter 2: Selectors)

3. Two rules have identical specificity and both set color. Which wins?

Order of appearance is the final tie-breaker: last declared wins. (Chapter 3: Cascade and specificity)

4. You want a semi-transparent background but fully opaque text. What should you use?

opacity fades children and text too; an alpha background color affects only the background. (Chapter 4: Colors)

5. Why is calc(100%-2rem) invalid?

- and + must be surrounded by whitespace inside calc(). (Chapter 5: Units and sizes)

6. Which layer shows the element's background color?

Backgrounds paint the content and padding area; margins are always transparent. (Chapter 6: Box model)

7. An element has font-size 20px and line-height 1.5. What is its computed line height?

A unitless line-height is multiplied by the element's own font size: 20 x 1.5 = 30px. (Chapter 7: Text and fonts)

8. What does flex: 1 on three sibling items do?

flex: 1 means grow 1, shrink 1, basis 0, so equal shares. (Chapter 8: Flexbox)

9. Which value makes an item span the full width of the grid?

Line 1 is the start and -1 is the last line. (Chapter 9: Grid layout)

10. What happens on a phone if the viewport meta tag is missing?

Without it, mobile browsers emulate a desktop-sized viewport. (Chapter 10: Media queries)

11. A .card sets --brand: red and :root sets --brand: blue. What does var(--brand) give for a button inside the card?

The nearest ancestor that defines the property wins, because custom properties inherit. (Chapter 11: Custom properties)

12. Which properties are usually cheapest to animate?

transform and opacity normally avoid recalculating layout on each frame. (Chapter 12: Transitions)

← Back to the CSS tutorial