Learn CSS

The style sheet language that lays out and styles every web page

27 lessons · 5 hours · 4 levels · covers CSS CSS (Baseline 2026)

CSS (Cascading Style Sheets) controls how HTML looks: colours, typography, spacing, layout, responsiveness and animation. Modern CSS has flexbox, grid, container queries, custom properties, cascade layers and nesting, so most layouts need no framework and no JavaScript. Every front-end developer, and anyone who builds web pages, needs it.

Before you start

CSS builds on these; the tree links to the exact lessons you need.

How deep do you want to go?

1. EssentialsRead and write simple code, do the everyday basics9 lessons · 1 hour in total
2. PracticalUse it productively at work, with the usual idioms17 lessons · 3 hours in total
3. AdvancedThe less common features, performance and trade-offs23 lessons · 4 hours in total
4. ExpertInternals and the edge cases experts know27 lessons · 5 hours in total

The CSS tree

CSSRules, declarations and linking CSSRules, declarationsand linking CSSSelectors and combinatorsSelectors andcombinatorsCascade, specificity and inheritanceCascade, specificityand inheritanceColours, units and valuesColours, units andvaluesThe box modelThe box modelDisplay and normal flowDisplay and normalflowTypography and web fontsTypography and webfontsBackgrounds, borders and shadowsBackgrounds,borders and shadowsFlexboxFlexboxPseudo-classes and pseudo-elementsPseudo-classes andpseudo-elementsPositioningPositioningCSS GridCSS GridSizing, overflow and aspect ratioSizing, overflow andaspect ratioCustom properties (CSS variables)Custom properties(CSS variables)Media queries and responsive designMedia queries andresponsive designTransitions and keyframe animationsTransitions andkeyframe animationsTransformsTransformsDocument structureDocument structureElements and attributesElements andattributesBlock, inline and generic containersBlock, inline andgeneric containersForms, inputs and labelsForms, inputs andlabelsHead metadata and SEOHead metadata andSEO
Essentials and Practical shown (17 of 27 lessons); the full list is below. Click a lesson to read it.

All 27 lessons, in order

Selectors and the cascade

  1. Rules, declarations and linking CSS · Essentials · 7 min

    A CSS rule is a selector plus declarations; attach styles with a linked stylesheet, a style element or inline styles.

  2. Selectors and combinators · Essentials · 10 min

    Target elements by type, class, id and attribute, and by their position in the tree with descendant, child and sibling combinators.

  3. Cascade, specificity and inheritance · Essentials · 12 min

    Learn how the browser picks a winner when several rules set the same property, and which properties children inherit.

  4. Colours, units and values · Essentials · 10 min

    Write colours in hex, rgb, hsl and oklch, and choose between px, rem, em, %, vw and other units for sizes.

  5. Pseudo-classes and pseudo-elements · Practical · 12 min

    Style elements by state or position with pseudo-classes like :hover and :nth-child, and generate content with ::before and ::after.

Box model and visuals

  1. The box model · Essentials · 10 min

    Every element is a box of content, padding, border and margin; box-sizing decides whether width includes padding and border.

  2. Typography and web fonts · Essentials · 10 min

    Style text with font-family stacks, size, weight, line-height and spacing, and load custom fonts efficiently with @font-face.

  3. Backgrounds, borders and shadows · Essentials · 8 min

    Decorate boxes with background colours, images and gradients, rounded borders, outlines and shadows.

  4. Sizing, overflow and aspect ratio · Practical · 10 min

    Control box sizes with min/max constraints, min(), max(), clamp(), aspect-ratio and object-fit, and handle content that overflows.

Layout

  1. Display and normal flow · Essentials · 8 min

    Control how a box takes part in layout with display: block, inline, inline-block, none, and understand normal flow.

  2. Flexbox · Essentials · 14 min

    Lay items out in a row or column with flexbox, distributing space and aligning them with justify-content, align-items and gap.

  3. Positioning · Practical · 12 min

    Move boxes out of normal flow with relative, absolute, fixed and sticky positioning and the inset properties.

  4. CSS Grid · Practical · 15 min

    Build two-dimensional layouts with grid-template-columns, fr units, repeat, minmax, auto-fit and named areas.

  5. z-index and stacking contexts · Advanced · 12 min

    Understand painting order, z-index and the stacking contexts that make a z-index: 9999 still appear behind something.

Modern CSS and architecture

  1. Custom properties (CSS variables) · Practical · 12 min

    Define reusable values with --name and read them with var(), with cascading, inheritance and fallbacks, to build themes.

  2. :is(), :where() and :has() · Advanced · 12 min

    Group selectors with :is() and zero-specificity :where(), and select parents and earlier siblings with :has().

  3. Native CSS nesting · Advanced · 8 min

    Write nested rules directly in CSS with & and nested at-rules, without a preprocessor.

  4. Cascade layers · Advanced · 12 min

    Organise styles into @layer groups so whole layers win or lose regardless of specificity, taming resets, libraries and utilities.

  5. Organising CSS at scale · Advanced · 12 min

    Keep large stylesheets maintainable with naming conventions like BEM, component scoping, @scope, design tokens and utility classes.

Responsive design

  1. Media queries and responsive design · Practical · 12 min

    Adapt layouts to screen size and user preferences with mobile-first media queries, range syntax and preference queries.

  2. Container queries · Advanced · 12 min

    Make components respond to the size of their container rather than the viewport with container-type and @container.

Motion and effects

  1. Transitions and keyframe animations · Practical · 12 min

    Animate changes between states with transition, and run multi-step animations with @keyframes and the animation property.

  2. Transforms · Practical · 8 min

    Move, rotate, scale and skew elements visually with transform and the individual translate, rotate and scale properties.

Rendering internals

  1. Formatting contexts and margin collapsing · Expert · 14 min

    Learn how block and inline formatting contexts work, when margins collapse, and how display: flow-root contains floats.

  2. The rendering pipeline and performance · Expert · 15 min

    Follow how style, layout, paint and composite turn CSS into pixels, and use that to avoid jank, layout thrashing and costly selectors.

  3. Modern colour: oklch, color-mix, relative colour · Expert · 12 min

    Use perceptual colour spaces, wide-gamut P3 colours, color-mix() and relative colour syntax to build palettes in pure CSS.

  4. Intrinsic sizing and the flex algorithm · Expert · 14 min

    Master min-content, max-content and fit-content, how flex items grow and shrink, and why min-width: auto causes overflow.