CSS Crash Course
Style real web pages with modern CSS. Selectors, the box model, typography, Flexbox, Grid, responsive design and motion, with small examples you can paste into a browser.
CSS decides how every element on a page looks and where it sits. This course starts with how the browser reads a stylesheet and ends with layouts that adapt from a phone to a wide monitor.
What you will learn
- How the cascade, inheritance and specificity decide which rule wins
- The box model, and why
box-sizing: border-boxsaves you from maths - Typography and colour with custom properties (CSS variables)
- One-dimensional layout with Flexbox and two-dimensional layout with Grid
- Responsive design with fluid sizes and media queries
- Transitions and animations that respect reduced-motion settings
Before you start
You should know basic HTML: elements, attributes, and how to open an .html file in a browser. If not, take HTML Crash Course first.
Every lesson has short code examples. Create an index.html and a styles.css next to each other, link them with <link rel="stylesheet" href="styles.css">, and try each example as you read.
Lessons
- 01How CSS works5 minRules, selectors and declarations, three ways to add CSS to a page, and how the cascade and inheritance decide what you see.
- 02Selectors and specificity5 minTarget exactly the elements you mean with type, class, attribute and pseudo-class selectors, and learn how the browser scores them.
- 03The box model5 minEvery element is a box of content, padding, border and margin. Learn how they add up, how display changes the box, and the one reset every project needs.
- 04Typography and colour5 minFonts, sizes, line height and measure, colour formats, and design tokens with CSS custom properties, including a dark theme in a few lines.
- 05Flexbox5 minLay out items in a row or a column, align them on both axes, share space between them, and build the navigation bars and card rows you see everywhere.
- 06CSS Grid5 minTwo-dimensional layout with rows and columns. Fixed and flexible tracks, the fr unit, auto-fill card grids, named areas, and when to choose Grid over Flexbox.
- 07Responsive design and motion5 minMobile-first CSS, media and container queries, fluid widths, responsive images, and transitions and animations that respect people who prefer less motion.