CSS

Beginner · Roadmap · 63 lessons · 10 groups

How CSS decides what a page looks like — selectors, the cascade and the box model — then layout with normal flow, Flexbox and Grid, typography, color and visual effects, responsive design, animation, the modern features that replaced preprocessor and JavaScript workarounds, and the architecture and tooling a large stylesheet needs. HTML is taught in html and the browser scripting layer in javascript. 63 lessons.

0%

Not started

Nothing saved yet. Progress is kept in this browser until you sign in.

Start the path

CSS foundations · 8

Layout fundamentals · 6

Typography · 6

Color and visual effects · 6

Flexbox · 4

Grid · 6

Responsive design · 6

Animation and motion · 6

Modern CSS · 6

Architecture and tooling · 9

01How CSS Works and Where It LivesWhat a CSS rule is made of, the three places styles can come from, and how the browser turns a stylesheet into the look of a page.Beginner · 4 min02Selectors and CombinatorsHow a CSS rule chooses which elements it applies to, from type, class and attribute selectors up to the four combinators that match by relationship.Beginner · 19 min03Pseudo-classes and Pseudo-elementsThe difference between selecting an element by state or position (pseudo-classes) and styling a part that has no tag of its own (pseudo-elements).Beginner · 6 min04Specificity and the CascadeHow the browser picks a winner when several rules set the same property on the same element, and how to read and control specificity instead of guessing.Beginner · 7 min05Inheritance and Computed ValuesWhy some properties flow from parent to child and others do not, the keywords that control it, and how a written value becomes the one the browser uses.Beginner · 6 min06Cascade Layers and ScopeHow @layer decides which group of styles wins before specificity is compared, and how @scope limits where a rule applies without fighting selector weight.Intermediate · 19 min07The Box Model and box-sizingHow every element becomes a rectangle of content, padding, border and margin, why width does not always mean what you expect, and what box-sizing changes.Beginner · 9 min08Values, Units and Math FunctionsHow to choose between px, rem, em, ch, percentages and viewport units, and how calc(), min(), max() and clamp() let one declaration adapt to its context.Beginner · 7 min01Display and Normal FlowHow block and inline boxes lay themselves out by default, what display actually controls, and when to take an element out of the flow.Beginner · 14 min02Margin Collapsing and Formatting ContextsWhy vertical margins sometimes merge into one, what a block formatting context is, and the small set of properties that stop the collapsing or contain floats.Intermediate · 15 min03Positioning and StickyThe five position values, how an absolutely positioned box finds its containing block, and why position sticky stops working when an ancestor has overflow set.Intermediate · 28 min04Stacking Contexts and z-indexWhy z-index 9999 sometimes loses to z-index 1, what creates a stacking context, and how isolation and the top layer keep overlapping UI predictable.Intermediate · 21 min05Overflow and Scroll ContainersWhat happens when content is bigger than its box, how hidden, clip, auto and scroll differ, and why overflow quietly changes layout and breaks position sticky.Intermediate · 11 min06Sizing Images and Replaced ElementsWhy images behave differently from other boxes, how intrinsic size and aspect ratio work, and the small reset that makes images safe in any layout.Beginner · 11 min01Font Families and Web FontsHow font-family fallback stacks work, what the generic families are for, and how @font-face loads your own files, and why self-hosted WOFF2 is the default.Beginner · 16 min02Variable Fonts and Font LoadingHow one variable font replaces a family, how axes are controlled from CSS, and how font-display and fallback metrics stop fonts delaying or shifting a page.Intermediate · 22 min03Text Spacing and ReadabilityHow line-height, line length, letter-spacing and paragraph spacing decide whether a block of text is comfortable to read, with values that are safe defaults.Beginner · 8 min04Fluid Typography with clamp()How to grow font sizes smoothly between a minimum and a maximum with clamp(), why the preferred value needs a rem part, and what progress() changes.Intermediate · 14 min05Text Wrapping and TruncationHow the browser breaks lines, how to handle long words and overflowing text with overflow-wrap and ellipsis, and what text-wrap balance and pretty change.Intermediate · 5 min06Writing Modes and Logical PropertiesHow writing-mode and direction change text and block flow, and how logical properties like margin-inline follow that flow instead of fixed screen sides.Intermediate · 21 min01Colors and Color SpacesHow CSS describes color, why HSL's lightness lies, and how oklch(), color-mix() and relative colors let you build a palette from one value.Beginner · 9 min02Backgrounds and GradientsHow an element's background layers stack, how background-size and positioning work, and how linear, radial and conic gradients are just generated images.Beginner · 11 min03Borders, Radius and OutlinesHow borders take up space, how border-radius rounds the corners and clips what's inside, and why outlines are the right tool for focus rings and debugging.Beginner · 10 min04Box Shadows and FiltersHow box-shadow's five numbers work, how to layer shadows so they look physical, and when filter, drop-shadow() and backdrop-filter are the better tool.Intermediate · 10 min05Clip-path, Masks and Blend ModesThree ways to change an element's pixels without editing an image: cut them away with clip-path, fade them with mask-image, or blend them with what's behind.Intermediate · 8 min06Transforms and 3DHow transform moves, rotates, scales and skews an element without touching layout, why function order matters, and how perspective makes a card 3D.Intermediate · 4 min01Flexbox FundamentalsWhat display - flex actually changes, how the main axis and cross axis work, and why items behave the way they do before you set a single other property.Beginner · 21 min02flex-grow, flex-shrink and flex-basisHow a flex container shares out extra space or takes it back, what the flex shorthand sets, and why items refuse to shrink until min-width is zero.Intermediate · 16 min03Alignment and GapHow justify-content, align-items, align-content and align-self split the work between the two axes, why auto margins help, and why gap beats margin.Intermediate · 14 min04Common Flexbox PatternsSix layouts you will build again and again, from centering and nav bars to sticky footers and media objects, and the flexbox property behind each.Intermediate · 16 min01Grid Fundamentals and TracksHow a grid container defines rows and columns before placing items, what the fr unit shares out, and why 1fr columns can blow past their container.Beginner · 7 min02Grid Areas and Named LinesHow to describe a layout as a picture with grid-template-areas, place items by name, and use named lines for layouts like a full-bleed column.Intermediate · 6 min03Auto-Placement and Responsive GridsHow grid auto-placement picks cells for items you did not position, what dense packing changes, and how auto-fit with minmax makes a grid responsive.Intermediate · 11 min04SubgridHow a nested grid can borrow its parent's rows or columns, so the insides of cards line up across a row even when their content differs in length.Intermediate · 4 min05Multi-Column LayoutHow column-count and column-width flow content into newspaper-style columns, how to control breaks and spanning, and why a fixed height spills columns.Intermediate · 9 min06Choosing Between Flexbox and GridA practical way to pick between Flexbox and Grid that goes past one dimension versus two, based on whether content or layout should be in charge.Intermediate · 10 min01Media Queries and Mobile-FirstHow media queries make styles conditional on viewport and device, why range syntax reads better than min-width and max-width, and what mobile-first buys.Beginner · 11 min02Container QueriesHow @container lets a component respond to the space it has rather than the screen size, what container-type does, and how container query units work.Intermediate · 17 min03Viewport Units and Dynamic ViewportsWhat vw and vh measure, why 100vh breaks on phones, and how the small, large and dynamic viewport units (svh, lvh, dvh) fix it.Intermediate · 6 min04Intrinsic and Fluid LayoutsHow to let content and the browser do the sizing with fluid widths, min() and clamp(), wrapping flex rows and auto-fit grids, so you need fewer breakpoints.Intermediate · 23 min05Aspect Ratio and Responsive MediaHow aspect-ratio reserves a box's shape, how object-fit crops images into it, and how width, height, srcset and picture keep images sharp without layout shift.Intermediate · 10 min06User Preference Queries and Dark ModeHow prefers-color-scheme, color-scheme and light-dark() build a system-following dark theme, and how reduced-motion and contrast queries adapt a page.Intermediate · 25 min01TransitionsHow a CSS transition eases a property change, how to control it per property and direction, and how @starting-style and allow-discrete animate entry and exit.Beginner · 18 min02Keyframe animationsHow @keyframes and the animation properties describe a self-running sequence, including fill modes, direction, negative delays and animating custom properties.Intermediate · 20 min03Animation performanceWhy some CSS animations stay smooth while others stutter, how style, layout, paint and composite set the cost, and how to measure it in DevTools.Intermediate · 12 min04Scroll snap and smooth scrollingHow scroll-snap-type and scroll-snap-align settle a scroller on chosen positions, how scroll-padding fixes sticky headers, and how scroll-behavior works.Intermediate · 7 min05Scroll-driven animationsHow animation-timeline lets scroll position or element visibility drive a normal @keyframes animation, using scroll() and view() timelines and a safe fallback.Advanced · 32 min06View transitionsHow the View Transitions API snapshots old and new state and animates between them, within a page or across navigations, using view-transition-name.Advanced · 14 min01Custom propertiesWhat CSS custom properties are, how they differ from preprocessor variables, how they inherit and cascade, and the patterns that make themes cheap.Beginner · 12 min02CSS nestingHow native nesting lets a rule contain its own selectors and at-rules, what & means for specificity, and where it differs from Sass nesting.Intermediate · 21 min03:is(), :where() and :has()How :is() and :where() shorten selector lists and differ in specificity, and how :has() lets a selector look at children and later siblings to style a parent.Intermediate · 14 min04@property and typed custom propertiesHow @property gives a custom property a type, an initial value and an inheritance rule, so the browser can animate it and reject bad values.Advanced · 11 min05Anchor positioning and popoversHow the popover attribute gives built-in open, close and light-dismiss, and how CSS anchor positioning tethers it to a trigger and flips it near an edge.Advanced · 20 min06@supports and progressive enhancementHow to adopt new CSS safely: a working baseline first, then features layered on with fallbacks, @supports and Baseline data to judge what is safe.Intermediate · 13 min01CSS architecture and BEMHow to keep a large stylesheet predictable with flat specificity, a layered file structure and BEM naming, including common mistakes and cascade layers.Intermediate · 16 min02Sass and preprocessorsWhat Sass adds on top of CSS, how @use and @forward replace the deprecated @import, and which of its features native CSS has since absorbed.Intermediate · 13 min03PostCSS and Lightning CSSHow PostCSS and Lightning CSS transform standard CSS at build time (prefixing, lowering syntax, minifying, bundling) and how browserslist shapes the output.Intermediate · 15 min04Utility-first CSS and TailwindWhat utility-first CSS is, why teams pick it over named classes, how Tailwind v4 generates CSS from your files, how @theme works and where it hurts.Intermediate · 11 min05CSS Modules and CSS-in-JSHow CSS Modules hash class names at build time, how CSS-in-JS generates styles from JavaScript, and how to choose between them and the alternatives.Intermediate · 12 min06Debugging CSS with DevToolsA working method for finding why a style is not applying, using the Styles and Computed panes, forced states, layout overlays and the Rendering tab.Beginner · 23 min07Accessible CSSHow CSS decides whether people can use a page: visible focus, forced-colors mode, reduced motion, scalable text, target size and hiding content properly.Intermediate · 14 min08CSS performanceWhere CSS really costs time, from render-blocking stylesheets to large-page recalculation, and the fixes: content-visibility, containment and measuring first.Advanced · 18 min09Print stylesheetsHow @media print and @page turn a web page into a clean printed or PDF document: hiding chrome, link URLs, page breaks, paper size, margins and testing.Intermediate · 16 min

CSS foundations

8 lessons

  1. 01 / 08How CSS Works and Where It LivesWhat a CSS rule is made of, the three places styles can come from, and how the browser turns a stylesheet into the look of a page.4 min
  2. 02 / 08Selectors and CombinatorsHow a CSS rule chooses which elements it applies to, from type, class and attribute selectors up to the four combinators that match by relationship.19 min
  3. 03 / 08Pseudo-classes and Pseudo-elementsThe difference between selecting an element by state or position (pseudo-classes) and styling a part that has no tag of its own (pseudo-elements).6 min
  4. 04 / 08Specificity and the CascadeHow the browser picks a winner when several rules set the same property on the same element, and how to read and control specificity instead of guessing.7 min
  5. 05 / 08Inheritance and Computed ValuesWhy some properties flow from parent to child and others do not, the keywords that control it, and how a written value becomes the one the browser uses.6 min
  6. 06 / 08Cascade Layers and ScopeHow @layer decides which group of styles wins before specificity is compared, and how @scope limits where a rule applies without fighting selector weight.19 min
  7. 07 / 08The Box Model and box-sizingHow every element becomes a rectangle of content, padding, border and margin, why width does not always mean what you expect, and what box-sizing changes.9 min
  8. 08 / 08Values, Units and Math FunctionsHow to choose between px, rem, em, ch, percentages and viewport units, and how calc(), min(), max() and clamp() let one declaration adapt to its context.7 min

Layout fundamentals

6 lessons

  1. 01 / 06Display and Normal FlowHow block and inline boxes lay themselves out by default, what display actually controls, and when to take an element out of the flow.14 min
  2. 02 / 06Margin Collapsing and Formatting ContextsWhy vertical margins sometimes merge into one, what a block formatting context is, and the small set of properties that stop the collapsing or contain floats.15 min
  3. 03 / 06Positioning and StickyThe five position values, how an absolutely positioned box finds its containing block, and why position sticky stops working when an ancestor has overflow set.28 min
  4. 04 / 06Stacking Contexts and z-indexWhy z-index 9999 sometimes loses to z-index 1, what creates a stacking context, and how isolation and the top layer keep overlapping UI predictable.21 min
  5. 05 / 06Overflow and Scroll ContainersWhat happens when content is bigger than its box, how hidden, clip, auto and scroll differ, and why overflow quietly changes layout and breaks position sticky.11 min
  6. 06 / 06Sizing Images and Replaced ElementsWhy images behave differently from other boxes, how intrinsic size and aspect ratio work, and the small reset that makes images safe in any layout.11 min

Typography

6 lessons

  1. 01 / 06Font Families and Web FontsHow font-family fallback stacks work, what the generic families are for, and how @font-face loads your own files, and why self-hosted WOFF2 is the default.16 min
  2. 02 / 06Variable Fonts and Font LoadingHow one variable font replaces a family, how axes are controlled from CSS, and how font-display and fallback metrics stop fonts delaying or shifting a page.22 min
  3. 03 / 06Text Spacing and ReadabilityHow line-height, line length, letter-spacing and paragraph spacing decide whether a block of text is comfortable to read, with values that are safe defaults.8 min
  4. 04 / 06Fluid Typography with clamp()How to grow font sizes smoothly between a minimum and a maximum with clamp(), why the preferred value needs a rem part, and what progress() changes.14 min
  5. 05 / 06Text Wrapping and TruncationHow the browser breaks lines, how to handle long words and overflowing text with overflow-wrap and ellipsis, and what text-wrap balance and pretty change.5 min
  6. 06 / 06Writing Modes and Logical PropertiesHow writing-mode and direction change text and block flow, and how logical properties like margin-inline follow that flow instead of fixed screen sides.21 min

Color and visual effects

6 lessons

  1. 01 / 06Colors and Color SpacesHow CSS describes color, why HSL's lightness lies, and how oklch(), color-mix() and relative colors let you build a palette from one value.9 min
  2. 02 / 06Backgrounds and GradientsHow an element's background layers stack, how background-size and positioning work, and how linear, radial and conic gradients are just generated images.11 min
  3. 03 / 06Borders, Radius and OutlinesHow borders take up space, how border-radius rounds the corners and clips what's inside, and why outlines are the right tool for focus rings and debugging.10 min
  4. 04 / 06Box Shadows and FiltersHow box-shadow's five numbers work, how to layer shadows so they look physical, and when filter, drop-shadow() and backdrop-filter are the better tool.10 min
  5. 05 / 06Clip-path, Masks and Blend ModesThree ways to change an element's pixels without editing an image: cut them away with clip-path, fade them with mask-image, or blend them with what's behind.8 min
  6. 06 / 06Transforms and 3DHow transform moves, rotates, scales and skews an element without touching layout, why function order matters, and how perspective makes a card 3D.4 min

Flexbox

4 lessons

  1. 01 / 04Flexbox FundamentalsWhat display - flex actually changes, how the main axis and cross axis work, and why items behave the way they do before you set a single other property.21 min
  2. 02 / 04flex-grow, flex-shrink and flex-basisHow a flex container shares out extra space or takes it back, what the flex shorthand sets, and why items refuse to shrink until min-width is zero.16 min
  3. 03 / 04Alignment and GapHow justify-content, align-items, align-content and align-self split the work between the two axes, why auto margins help, and why gap beats margin.14 min
  4. 04 / 04Common Flexbox PatternsSix layouts you will build again and again, from centering and nav bars to sticky footers and media objects, and the flexbox property behind each.16 min

Grid

6 lessons

  1. 01 / 06Grid Fundamentals and TracksHow a grid container defines rows and columns before placing items, what the fr unit shares out, and why 1fr columns can blow past their container.7 min
  2. 02 / 06Grid Areas and Named LinesHow to describe a layout as a picture with grid-template-areas, place items by name, and use named lines for layouts like a full-bleed column.6 min
  3. 03 / 06Auto-Placement and Responsive GridsHow grid auto-placement picks cells for items you did not position, what dense packing changes, and how auto-fit with minmax makes a grid responsive.11 min
  4. 04 / 06SubgridHow a nested grid can borrow its parent's rows or columns, so the insides of cards line up across a row even when their content differs in length.4 min
  5. 05 / 06Multi-Column LayoutHow column-count and column-width flow content into newspaper-style columns, how to control breaks and spanning, and why a fixed height spills columns.9 min
  6. 06 / 06Choosing Between Flexbox and GridA practical way to pick between Flexbox and Grid that goes past one dimension versus two, based on whether content or layout should be in charge.10 min

Responsive design

6 lessons

  1. 01 / 06Media Queries and Mobile-FirstHow media queries make styles conditional on viewport and device, why range syntax reads better than min-width and max-width, and what mobile-first buys.11 min
  2. 02 / 06Container QueriesHow @container lets a component respond to the space it has rather than the screen size, what container-type does, and how container query units work.17 min
  3. 03 / 06Viewport Units and Dynamic ViewportsWhat vw and vh measure, why 100vh breaks on phones, and how the small, large and dynamic viewport units (svh, lvh, dvh) fix it.6 min
  4. 04 / 06Intrinsic and Fluid LayoutsHow to let content and the browser do the sizing with fluid widths, min() and clamp(), wrapping flex rows and auto-fit grids, so you need fewer breakpoints.23 min
  5. 05 / 06Aspect Ratio and Responsive MediaHow aspect-ratio reserves a box's shape, how object-fit crops images into it, and how width, height, srcset and picture keep images sharp without layout shift.10 min
  6. 06 / 06User Preference Queries and Dark ModeHow prefers-color-scheme, color-scheme and light-dark() build a system-following dark theme, and how reduced-motion and contrast queries adapt a page.25 min

Animation and motion

6 lessons

  1. 01 / 06TransitionsHow a CSS transition eases a property change, how to control it per property and direction, and how @starting-style and allow-discrete animate entry and exit.18 min
  2. 02 / 06Keyframe animationsHow @keyframes and the animation properties describe a self-running sequence, including fill modes, direction, negative delays and animating custom properties.20 min
  3. 03 / 06Animation performanceWhy some CSS animations stay smooth while others stutter, how style, layout, paint and composite set the cost, and how to measure it in DevTools.12 min
  4. 04 / 06Scroll snap and smooth scrollingHow scroll-snap-type and scroll-snap-align settle a scroller on chosen positions, how scroll-padding fixes sticky headers, and how scroll-behavior works.7 min
  5. 05 / 06Scroll-driven animationsHow animation-timeline lets scroll position or element visibility drive a normal @keyframes animation, using scroll() and view() timelines and a safe fallback.32 min
  6. 06 / 06View transitionsHow the View Transitions API snapshots old and new state and animates between them, within a page or across navigations, using view-transition-name.14 min

Modern CSS

6 lessons

  1. 01 / 06Custom propertiesWhat CSS custom properties are, how they differ from preprocessor variables, how they inherit and cascade, and the patterns that make themes cheap.12 min
  2. 02 / 06CSS nestingHow native nesting lets a rule contain its own selectors and at-rules, what & means for specificity, and where it differs from Sass nesting.21 min
  3. 03 / 06:is(), :where() and :has()How :is() and :where() shorten selector lists and differ in specificity, and how :has() lets a selector look at children and later siblings to style a parent.14 min
  4. 04 / 06@property and typed custom propertiesHow @property gives a custom property a type, an initial value and an inheritance rule, so the browser can animate it and reject bad values.11 min
  5. 05 / 06Anchor positioning and popoversHow the popover attribute gives built-in open, close and light-dismiss, and how CSS anchor positioning tethers it to a trigger and flips it near an edge.20 min
  6. 06 / 06@supports and progressive enhancementHow to adopt new CSS safely: a working baseline first, then features layered on with fallbacks, @supports and Baseline data to judge what is safe.13 min

Architecture and tooling

9 lessons

  1. 01 / 09CSS architecture and BEMHow to keep a large stylesheet predictable with flat specificity, a layered file structure and BEM naming, including common mistakes and cascade layers.16 min
  2. 02 / 09Sass and preprocessorsWhat Sass adds on top of CSS, how @use and @forward replace the deprecated @import, and which of its features native CSS has since absorbed.13 min
  3. 03 / 09PostCSS and Lightning CSSHow PostCSS and Lightning CSS transform standard CSS at build time (prefixing, lowering syntax, minifying, bundling) and how browserslist shapes the output.15 min
  4. 04 / 09Utility-first CSS and TailwindWhat utility-first CSS is, why teams pick it over named classes, how Tailwind v4 generates CSS from your files, how @theme works and where it hurts.11 min
  5. 05 / 09CSS Modules and CSS-in-JSHow CSS Modules hash class names at build time, how CSS-in-JS generates styles from JavaScript, and how to choose between them and the alternatives.12 min
  6. 06 / 09Debugging CSS with DevToolsA working method for finding why a style is not applying, using the Styles and Computed panes, forced states, layout overlays and the Rendering tab.23 min
  7. 07 / 09Accessible CSSHow CSS decides whether people can use a page: visible focus, forced-colors mode, reduced motion, scalable text, target size and hiding content properly.14 min
  8. 08 / 09CSS performanceWhere CSS really costs time, from render-blocking stylesheets to large-page recalculation, and the fixes: content-visibility, containment and measuring first.18 min
  9. 09 / 09Print stylesheetsHow @media print and @page turn a web page into a clean printed or PDF document: hiding chrome, link URLs, page breaks, paper size, margins and testing.16 min
Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark