Skip to content
Kuza Ndoto Academy

CSS Quiz

Beginner → IntermediateChapter 6 · Page 22 of 224 min readUpdated 15 Nov 2026

Test what you've learned across the CSS series. Try each question before opening the answer. If you get one wrong, follow the link back to the page that covers it.

Getting started

1. What does CSS stand for, and what is its job?

Show answer

Cascading Style Sheets. It controls how HTML is presented: colour, typography, spacing, layout and animation. See CSS Introduction.

2. Which way of adding CSS is best for a website with twenty pages: inline, internal or external?

Show answer

External, a .css file linked from every page with <link rel="stylesheet">. One file styles every page and the browser caches it.

3. What is the difference between .menu a and .menu > a?

Show answer

.menu a matches links at any depth inside .menu; .menu > a matches only links that are direct children of .menu. See Syntax & Selectors.

4. Which colour is hsl(0 100% 50%)?

Show answer

Pure red. Hue 0° is red, 100% saturation is fully vivid and 50% lightness is the pure colour (the same as #ff0000).

5. With the browser's default settings, how many pixels is 1.5rem?

Show answer

24px. The default root font size is 16px, and 16 × 1.5 = 24. Unlike em, rem doesn't compound when nested.

Box model and display

6. A box has width: 200px; padding: 10px; border: 2px solid; and the default box-sizing. How wide does it appear on screen? What changes with border-box?

Show answer

224px (200 + 10 + 10 + 2 + 2), because content-box adds padding and border to the width. With box-sizing: border-box it is exactly 200px and the content shrinks to 176px. See The Box Model.

7. What is the difference between display: none and visibility: hidden?

Show answer

display: none removes the element from the layout entirely, so the space closes up. visibility: hidden hides it but keeps its space.

Layout

8. An element has position: absolute; top: 0; right: 0;. What is it positioned relative to?

Show answer

Its nearest positioned ancestor (any ancestor whose position isn't static), or the initial containing block (the page) if there isn't one. That's why parents often get position: relative. See Positioning.

9. In a flex container with flex-direction: column, which direction does justify-content control?

Show answer

Vertical. justify-content always works along the main axis, and in a column the main axis runs top to bottom. See Flexbox.

10. What does grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)) do?

Show answer

It creates as many columns as will fit, each at least 250px wide, then stretches them equally to fill the row. The number of columns adapts to the screen without any media query. See CSS Grid.

11. In a mobile-first stylesheet, do your media queries mostly use min-width or max-width? Why?

Show answer

min-width. Base styles target small screens, and each min-width query adds enhancements once the screen is wide enough. See Responsive Design.

Selectors, cascade and effects

12. What is the specificity of #nav ul li.active a, written as inline, IDs, classes, elements?

Show answer

0,1,1,3. One ID (#nav), one class (.active) and three elements (ul, li, a). See Specificity & the Cascade.

13. A button matches both .btn.primary.large { color: blue; } and #buy { color: green; }, and the class rule comes later. What colour is it?

Show answer

Green. One ID (0,1,0,0) beats any number of classes (here 0,0,3,0). Source order only matters when specificity is equal.

14. Which two properties are the cheapest and smoothest to animate, and why?

Show answer

transform and opacity. Changing them doesn't force the browser to recalculate the layout, so they can be animated smoothly, often on the graphics chip. See Transitions & Animations.

Modern CSS

15. What colour is the text in p { color: var(--brand, orange); } if --brand has never been declared? And what does .card:has(img) select?

Show answer

Orange: the second argument of var() is the fallback used when the variable isn't defined. .card:has(img) selects every .card that contains an image. See CSS Variables and Modern CSS Features.

Key points

  • Scored 12 or more? You're ready to style real projects; try the landing page project.
  • Revisit the box model and specificity pages if those questions caught you out; they cause most real-world CSS bugs.
  • Keep practising with DevTools: inspect sites you like and see how their CSS works.
  • Next, add interactivity with the JavaScript series.
You've reached the end of the seriesGet certified in CSSContinue in Kuza Ndoto Academy with projects, mentor feedback and a certificate.
→

Tip: use the ← and → keys to move between pages.