CSS Course Outline: From Selectors to Modern Layout and Motion
A complete, current CSS course for students and working developers: selectors and the cascade, units and color, the box model, flexbox and grid, positioning and anchor positioning, responsive and container queries, typography, effects, animation and view transitions, and CSS architecture.
kvi5hnuCode Sprout team member13 min readOn this page
This course teaches CSS from your first rule to the features that arrived in browsers in the last few years: cascade layers, nesting, :has(), container queries, anchor positioning, OKLCH colors, scroll-driven animations and view transitions. It's written for two kinds of reader:
- Students and beginners who know some HTML and want to style pages properly. Part 1 starts from what CSS is, and every article builds only on the ones before it.
- Working developers who write CSS every day but want to stop fighting it: to understand why the cascade picks the value it does, why a layout behaves the way it does, and which modern features can replace old workarounds. Each article has a "Common questions" section for the doubts people really have, and the delicate details are tested in the quizzes.
How the course works
- Current CSS. Everything is checked against current browsers (Chrome 158, Firefox 160 and Safari 27, as of November 2026) and the latest specifications. Each article ends with a What's current section saying which features are Baseline, meaning they work in all major browsers, and which still need a fallback. Older techniques you'll still meet in existing code, such as floats for layout or
-webkit-prefixes, are explained alongside the modern ones. - Live examples. Most examples are small HTML and CSS snippets that render in the page. Edit the CSS, and the preview updates. Each preview is an empty page with only the browser's default styles, so what you see comes from the example alone. You can edit the HTML, CSS and JavaScript tabs, open the console, and open any example in the full Playground to experiment further.
- Pictures for the hard parts. Diagrams show what can't be seen directly, such as the box model, the cascade's order of precedence, grid lines and stacking contexts, and rendered screenshots show what a technique produces.
- One example site. Most examples style parts of Harbor Books, a small independent bookshop's website, with a header and navigation, book cards, an events list and a newsletter form, so you can focus on the CSS instead of the content.
- Practice at every step. Every article ends with practice questions and answers, Parts 1 to 17 each end with a review quiz, Part 18 is a set of graded exercises, and three final quizzes test the whole course.
You'll need a current browser, and a text editor if you want to build pages of your own. Article 4 covers the browser developer tools, which you'll use throughout the course.
What you'll learn
| Part | Topic | What it covers | Articles |
|---|---|---|---|
| 1 | Getting started | What CSS is and how browsers apply it, the ways to add CSS to a page, the syntax and how browsers recover from errors, DevTools, the kinds of boxes elements generate, and using new features safely. | 1–6 |
| 2 | Selectors | Every way to target elements: type, class, ID and attribute selectors, combinators, structural and state pseudo-classes, (), (), () and (), pseudo-elements, and styling web components. | 7–14 |
| 3 | The cascade | How CSS decides which value wins: specificity, inheritance, origins and !important, the global keywords, shorthand traps, cascade layers, nesting and @scope. | 15–22 |
| 4 | Values and units | The values CSS works with: value types, length units, viewport units, math functions, custom properties and @property, and the new dynamic functions attr(), if() and custom functions. | 23–30 |
| 5 | Color | Color formats from hex to OKLCH, color spaces and gamuts, mixing and deriving colors, light and dark themes, and designing for contrast and accessibility. | 31–35 |
| 6 | Boxes and visual formatting | The box model and box-sizing, sizing, aspect ratios, padding and margins, margin collapsing, borders and outlines, overflow, normal flow and formatting contexts, line layout, hiding content, and logical properties. | 36–47 |
| 7 | Backgrounds, gradients and shadows | Background colors and images, multiple backgrounds, linear, radial and conic gradients, box and text shadows, and responsive images. | 48–53 |
| 8 | Floats and positioning | Floats and CSS shapes, relative, absolute, fixed and sticky positioning, stacking contexts and z-index, anchor positioning, and popovers and dialogs in the top layer. | 54–60 |
| 9 | Flexbox | One-dimensional layout: flex containers and axes, how flex items grow and shrink, alignment and gaps, visual order and accessibility, and common flexbox patterns. | 61–65 |
| 10 | Grid | Two-dimensional layout: tracks and lines, track sizing, placing items, the implicit grid, alignment, subgrid, masonry with grid lanes, multi-column layout and tables. | 66–74 |
| 11 | Responsive design | Pages and components that adapt: mobile-first design, media queries, fluid layouts and type, container size, style and scroll-state queries, feature queries, and print styles. | 75–81 |
| 12 | Typography | Fonts and text: font stacks, web fonts and loading performance, size, weight and style, OpenType features, variable fonts, alignment and spacing, decoration, wrapping, writing modes, and readable typography. | 82–93 |
| 13 | Lists and generated content | Styling lists and markers, inserting content with ::before and ::after, counters, and custom counter styles. | 94–97 |
| 14 | Visual effects | Filters and backdrop filters, blend modes, clipping paths, masks, and styling form controls. | 98–102 |
| 15 | Transforms | Moving, rotating, scaling and skewing elements in 2D, transform order and matrices, and 3D transforms with perspective. | 103–105 |
| 16 | Motion | Transitions and timing functions, transitioning display and auto sizes, keyframe animations, performance, accessible motion, scroll-driven animations, view transitions, scroll snap and CSS carousels. | 106–115 |
| 17 | Architecture and practice | Writing CSS that scales: modular components and naming, organizing with layers, design tokens and theming, pattern libraries, preprocessors and tooling, at-rules, and a debugging guide. | 116–122 |
| 18 | Exercises | Graded hands-on exercise sets with explained solutions, from selectors and the box model to modern layout and motion. | 123–125 |
Part 1: Getting started
What CSS is and how browsers apply it, the ways to add CSS to a page, the syntax and how browsers recover from errors, DevTools, the kinds of boxes elements generate, and using new features safely.
- What CSS Is: Styling Documents, Standards, Browsers and Baseline
- Adding CSS to a Page: link, style, @import and Inline Styles
- CSS Syntax: Rules, Declarations, Comments, and How Browsers Handle Errors
- Using Browser DevTools for CSS: Inspecting, Computed Styles and Live Editing
- Elements and Boxes: Block, Inline, Replaced Elements and the display Property
- Progressive Enhancement: Fallbacks, @supports and Writing CSS That Degrades Gracefully
Part 2: Selectors
Every way to target elements: type, class, ID and attribute selectors, combinators, structural and state pseudo-classes, (), (), () and (), pseudo-elements, and styling web components.
- Basic Selectors: Type, Class, ID, Universal and Grouping
- Attribute Selectors: Presence, Exact, Partial Matches and Case Sensitivity
- Combinators: Descendant, Child, Next-Sibling and Subsequent-Sibling Selectors
- Structural Pseudo-Classes: (), (), of S and Friends
- State Pseudo-Classes: Links, , , and Form States
- Logical Pseudo-Classes: (), (), () and the () Parent Selector
- Pseudo-Elements: ::before, ::after, ::first-line, ::marker, ::selection and More
- Styling Web Components: , ::slotted(), ::part() and ()
Part 3: The cascade
How CSS decides which value wins: specificity, inheritance, origins and !important, the global keywords, shorthand traps, cascade layers, nesting and @scope.
- Specificity: How CSS Decides Which Selector Wins
- Inheritance: Which Properties Pass Down and Why
- The Cascade: Origins, !important, Inline Styles and Source Order
- Global Keywords: inherit, initial, unset, revert, revert-layer and all
- Shorthand Properties: How They Reset Values and the Order of Their Parts
- Cascade Layers: @layer, Layer Order and Taming Specificity
- CSS Nesting: The & Selector, Nested At-Rules and Their Subtleties
- @scope: Limiting Where Styles Apply, Scope Limits and Proximity
Part 4: Values and units
The values CSS works with: value types, length units, viewport units, math functions, custom properties and @property, and the new dynamic functions attr(), if() and custom functions.
- CSS Value Types: Keywords, Strings, URLs, Numbers and Percentages
- Length Units: px, em, rem, ch, lh and the Other Font-Relative Units
- Viewport Units: vw, vh, and the Small, Large and Dynamic Viewport Units
- Math Functions: calc(), min(), max(), clamp(), round() and Trigonometry
- Custom Properties: Variables, Fallbacks, Scope and Changing Them at Runtime
- Registered Custom Properties With @property: Types, Inheritance and Animation
- Angles, Times, Resolutions, Ratios, Positions and Images
- Dynamic Values: attr(), if(), Custom Functions and sibling-index()
Part 5: Color
Color formats from hex to OKLCH, color spaces and gamuts, mixing and deriving colors, light and dark themes, and designing for contrast and accessibility.
- Color Basics: Names, Hex, rgb(), hsl(), hwb(), currentColor and Transparency
- Color Spaces and Gamuts: lab(), lch(), oklab(), oklch() and color()
- Mixing and Deriving Colors: color-mix() and Relative Color Syntax
- Light and Dark Themes: color-scheme, light-dark(), System Colors and accent-color
- Color Contrast and Accessibility: WCAG Ratios, contrast-color() and Forced Colors
Part 6: Boxes and visual formatting
The box model and box-sizing, sizing, aspect ratios, padding and margins, margin collapsing, borders and outlines, overflow, normal flow and formatting contexts, line layout, hiding content, and logical properties.
- The Box Model: Content, Padding, Border, Margin and box-sizing
- Sizing Boxes: width, height, Logical Sizes, min/max and Intrinsic Sizes
- aspect-ratio, object-fit and object-position for Media and Boxes
- Padding and Margins: Percentages, auto Centering and Negative Margins
- Margin Collapsing: When Vertical Margins Combine and How to Stop It
- Borders: Styles, Widths, Colors, border-radius, border-image and corner-shape
- Outlines and Focus Indicators: outline, outline-offset and Accessible Focus Styles
- Overflow: Scroll Containers, overflow: clip, text-overflow, line-clamp and Scrollbars
- Normal Flow, the Containing Block and Block Formatting Contexts
- Inline Formatting: Line Boxes, line-height, vertical-align and text-box-trim
- Hiding and Showing: display: none, visibility, display: contents and content-visibility
- Logical Properties and Writing Modes: inline, block, start and end
Part 7: Backgrounds, gradients and shadows
Background colors and images, multiple backgrounds, linear, radial and conic gradients, box and text shadows, and responsive images.
- Backgrounds: Colors, Images, Position, Size, Repeat, Clip and Origin
- Multiple Backgrounds and the background Shorthand
- Linear Gradients: Directions, Color Stops, Hints and Repeating Gradients
- Radial and Conic Gradients, and Choosing the Interpolation Color Space
- Shadows: box-shadow, text-shadow and Designing Depth
- Responsive Images: srcset, sizes, picture and image-set()
Part 8: Floats and positioning
Floats and CSS shapes, relative, absolute, fixed and sticky positioning, stacking contexts and z-index, anchor positioning, and popovers and dialogs in the top layer.
- Floats and Clearing: Wrapping Text Around Content
- CSS Shapes: shape-outside, shape-margin and Non-Rectangular Text Wrap
- Positioning: relative, absolute, Offsets, inset and the Containing Block
- Fixed and Sticky Positioning: Headers, Modals and Sticky Sections
- Stacking Contexts and z-index: Why Your z-index Doesn't Work
- Anchor Positioning: Tethering Tooltips and Menus With anchor() and position-area
- Popovers, Dialogs and the Top Layer: Styling, ::backdrop and Entry Animations
Part 9: Flexbox
One-dimensional layout: flex containers and axes, how flex items grow and shrink, alignment and gaps, visual order and accessibility, and common flexbox patterns.
- Flexbox Basics: Flex Containers, Axes, flex-direction and flex-wrap
- Flex Sizing: flex-basis, flex-grow, flex-shrink and the flex Shorthand
- Alignment in Flexbox: justify-content, align-items, gap and auto Margins
- Visual Order and Accessibility: order, reading-flow and Reversed Directions
- Flexbox in Practice: Navigation Bars, Media Objects, Sticky Footers and Forms
Part 10: Grid
Two-dimensional layout: tracks and lines, track sizing, placing items, the implicit grid, alignment, subgrid, masonry with grid lanes, multi-column layout and tables.
- Grid Basics: Grid Containers, Tracks, Lines, Cells and the fr Unit
- Grid Track Sizing: repeat(), minmax(), auto-fill, auto-fit and Intrinsic Sizes
- Placing Grid Items: Line Numbers, Spans, Named Lines and grid-template-areas
- The Implicit Grid and Auto-Placement: grid-auto-rows, grid-auto-flow and dense
- Aligning Grid Items and Tracks, Overlapping Items, and the grid Shorthand
- Subgrid: Aligning Nested Content to the Parent Grid
- Masonry Layouts With Grid Lanes
- Multi-Column Layout: columns, column-span and Fragmentation
- Table Layout: Table Display, Borders, Sizing and Responsive Tables
Part 11: Responsive design
Pages and components that adapt: mobile-first design, media queries, fluid layouts and type, container size, style and scroll-state queries, feature queries, and print styles.
- Responsive Design: Mobile First, the Viewport Meta Tag and Breakpoints
- Media Queries: Media Types, Range Syntax, and User-Preference Features
- Fluid Layouts and Fluid Typography With clamp()
- Container Queries: Size Containers, Container Names and Container Units
- Container Style Queries and Scroll-State Queries
- Feature Queries in Depth: @supports, selector() and font-tech()
- Print Styles: @media print, @page, Page Breaks and Margin Boxes
Part 12: Typography
Fonts and text: font stacks, web fonts and loading performance, size, weight and style, OpenType features, variable fonts, alignment and spacing, decoration, wrapping, writing modes, and readable typography.
- Font Families: Generic Families, Font Stacks and System Fonts
- Web Fonts: @font-face, Formats, unicode-range and Multiple Styles
- Font Loading and Performance: font-display, Preloading and Fallback Metrics
- Font Size, Weight, Style, Stretch and Synthesis
- OpenType Features: font-variant, Numerals, Ligatures and font-feature-settings
- Variable Fonts: Axes, font-variation-settings and Optical Sizing
- The font Shorthand and How Browsers Match Fonts
- Text Alignment, Indentation, Spacing and text-transform
- Text Decoration, Underline Offsets, Emphasis Marks and Text Shadows
- White Space, Line Breaking, Hyphenation and text-wrap: balance and pretty
- Writing Modes, Direction and Vertical Text
- Readable Typography: Measure, Line Height, Vertical Rhythm and Spacing
Part 13: Lists and generated content
Styling lists and markers, inserting content with ::before and ::after, counters, and custom counter styles.
- Styling Lists: list-style, Marker Position and ::marker
- Generated Content: the content Property, Quotes and attr()
- CSS Counters: counter-reset, counter-increment and Nested Numbering
- Custom Counter Styles With @counter-style
Part 14: Visual effects
Filters and backdrop filters, blend modes, clipping paths, masks, and styling form controls.
- Filters: blur(), drop-shadow(), Color Filters and backdrop-filter
- Blend Modes: background-blend-mode, mix-blend-mode and isolation
- Clipping: clip-path With inset(), circle(), polygon(), path() and shape()
- Masking: mask-image, Luminance and Alpha Masks, and the mask Properties
- Styling Forms: appearance, accent-color, field-sizing and Customizable select
Part 15: Transforms
Moving, rotating, scaling and skewing elements in 2D, transform order and matrices, and 3D transforms with perspective.
- 2D Transforms: translate, rotate, scale, skew and the Individual Transform Properties
- Transform Origin, Order of Transforms and the Matrix Functions
- 3D Transforms: Perspective, preserve-3d and Backfaces
Part 16: Motion
Transitions and timing functions, transitioning display and auto sizes, keyframe animations, performance, accessible motion, scroll-driven animations, view transitions, scroll snap and CSS carousels.
- Transitions: Animating Between States With transition
- Timing Functions: Easing Keywords, cubic-bezier(), steps() and linear()
- Transitioning the Hard Cases: display, Height auto, @starting-style and allow-discrete
- Keyframe Animations: @keyframes and the animation Properties
- Animation in Depth: Fill Modes, Direction, Composition, Events and Interruptions
- Animation Performance: The Rendering Pipeline, Compositing and will-change
- Accessible Motion: prefers-reduced-motion and Meaningful Animation
- Scroll-Driven Animations: scroll(), view() and Animation Ranges
- View Transitions: Animating Between Page States and Between Pages
- Scroll Snap and CSS Carousels: scroll-snap-type, ::scroll-button and ::scroll-marker
Part 17: Architecture and practice
Writing CSS that scales: modular components and naming, organizing with layers, design tokens and theming, pattern libraries, preprocessors and tooling, at-rules, and a debugging guide.
- Modular CSS: Components, Variants, Naming Conventions and BEM
- Organizing a Stylesheet With Layers: Reset, Theme, Layout, Components and Utilities
- Design Tokens and Theming With Custom Properties
- Pattern Libraries, a CSS-First Workflow and Refactoring Safely
- Preprocessors and Tooling: Sass, PostCSS, Lightning CSS and What Native CSS Replaced
- CSS At-Rules Reference: @import, @namespace, @media, @supports, @layer and the Rest
- Debugging CSS and Best Practices: A Troubleshooting Guide
Part 18: Exercises
Graded hands-on exercise sets with explained solutions, from selectors and the box model to modern layout and motion.
- CSS Exercises: Beginner (Selectors, Cascade, Box Model and Color)
- CSS Exercises: Intermediate (Flexbox, Grid, Positioning and Responsive Design)
- CSS Exercises: Advanced (Modern Layout, Motion, Container Queries and Architecture)
After the course: final quizzes
Start here: What CSS Is: Styling Documents, Standards, Browsers and Baseline

More in CSS Course
Quiz: CSS Delicate Details
Twenty-five questions on the edge cases that surprise experienced developers: invalid custom properties, shorthands that reset values, layer order with !important, containing blocks, margin collapsing, specificity of :is() and :where(), intrinsic minimum sizes, and more, each checked in Chrome.
Quiz: CSS Interview Questions
Thirty front-end interview questions: cascade, specificity and layers, box model and margin collapsing, stacking contexts, positioning, flexbox and grid, responsive design, custom properties, performance, accessibility, modern selectors and architecture.
Quiz: CSS Course Final Exam
Thirty questions across the whole CSS course: syntax and error handling, selectors, the cascade and layers, values and units, color, the box model, backgrounds, positioning, flexbox, grid, responsive design, typography, generated content, effects, transforms, motion and architecture.
Quiz: CSS Architecture, Tooling and Debugging (CSS Part 17)
Twenty questions on modular CSS and BEM, layering a stylesheet, design tokens and theming, pattern libraries and safe refactoring, preprocessors and build tools, the at-rules reference, and debugging common CSS problems.
Discussion
Sign in to ask a question or share what you learned.