2 Quizzes•15 Questions

Learn CSS

Most CSS confusion comes from three ideas: the cascade, the box model and layout modes. These quizzes make you predict what the browser will do.

What you will practise

  • Specificity and the cascade
  • The box model and sizing
  • Flexbox and Grid layout
  • Responsive, mobile-first design

CSS lesson

A short introduction to the ideas behind the quizzes, before you start practising.

CSS controls how a page looks. Most CSS frustration comes from three things: not knowing which rule the cascade will actually apply, misunderstanding the box model, and mixing up flexbox and grid.

Key concepts

The cascade and specificity

When several rules target the same element, the browser picks a winner using specificity (roughly: ID beats class beats element) and, if specificity ties, the rule that appears later in the source.

.card { color: blue; }     /* specificity 0-1-0 */
#hero { color: red; }      /* specificity 1-0-0, wins */

The box model

Every element is a box made of content, padding, border and margin. With the default `box-sizing: content-box`, `width` sets only the content area, so padding and border add to the element’s total size; `border-box` includes them instead.

.box {
  box-sizing: border-box;
  width: 200px;
  padding: 20px;
  border: 2px solid black;
} /* total width stays 200px */

Flexbox for one dimension

Flexbox distributes items along a single row or column. `justify-content` aligns along the main axis, `align-items` along the cross axis, and the axes swap when `flex-direction` is `column`.

.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

Grid for two dimensions

Grid lays items out in rows and columns at the same time, which suits full page layouts and galleries better than flexbox does. The two are often combined: grid for the page, flexbox inside individual cards.

.gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

Common mistakes

  • Fighting specificity with `!important` instead of understanding why a rule is not applying.
  • Forgetting that `width` excludes padding and border under the default `box-sizing`, leading to layouts that are wider than expected.
  • Mixing up `justify-content` and `align-items` after changing `flex-direction`, since the axes swap.
  • Reaching for absolute positioning to centre something that flexbox or grid could centre without it.

Quick recap

  • Specificity, then source order, decides which conflicting rule wins.
  • Use `box-sizing: border-box` to make width predictable when padding and borders are involved.
  • Flexbox distributes items along one axis; grid arranges rows and columns together.
  • Prefer layout tools (flexbox/grid) over manual positioning for alignment.

Ready to test this? Take the CSS Fundamentals quiz →

Roadmap

Work through the levels in order, or jump to where you are.

1

Beginner

Core ideas

  • Specificity
  • Box model
  • Units
  • Display

CSS Fundamentals

3

Intermediate

Modern layout

  • Flexbox
  • Grid
  • Media queries
  • Positioning

Flexbox, Grid & Responsive Layout

CSS quizzes

Interactive CSS challenges

Hands-on activities: find bugs, complete code, order steps and match concepts.

All CSS challenges →

CSS articles

FAQ

Do the quizzes cover Sass or Tailwind?

No. They cover standard CSS, which applies to every tool built on it.