CSS
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.
How 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.Selectors 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.Pseudo-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).Specificity 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.Inheritance 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.Cascade 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.The 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.Values, 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.Display 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.Margin 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.Positioning 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.Stacking 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.Overflow 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.Sizing 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.Font 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.Variable 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.Text 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.Fluid 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.Text 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.Writing 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.Colors 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.Backgrounds 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.Borders, 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.Box 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.Clip-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.Transforms and 3DHow transform moves, rotates, scales and skews an element without touching layout, why function order matters, and how perspective makes a card 3D.Flexbox 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.flex-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.Alignment 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.Common 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.Grid 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.Grid 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.Auto-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.SubgridHow 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.Multi-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.Choosing 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.Media 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.Container 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.Viewport 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.Intrinsic 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.Aspect 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.User 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.TransitionsHow 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.Keyframe animationsHow @keyframes and the animation properties describe a self-running sequence, including fill modes, direction, negative delays and animating custom properties.Animation 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.Scroll 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.Scroll-driven animationsHow animation-timeline lets scroll position or element visibility drive a normal @keyframes animation, using scroll() and view() timelines and a safe fallback.View transitionsHow the View Transitions API snapshots old and new state and animates between them, within a page or across navigations, using view-transition-name.Custom propertiesWhat CSS custom properties are, how they differ from preprocessor variables, how they inherit and cascade, and the patterns that make themes cheap.CSS nestingHow native nesting lets a rule contain its own selectors and at-rules, what & means for specificity, and where it differs from Sass nesting.: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.@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.Anchor 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.@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.CSS 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.Sass 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.PostCSS and Lightning CSSHow PostCSS and Lightning CSS transform standard CSS at build time (prefixing, lowering syntax, minifying, bundling) and how browserslist shapes the output.Utility-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.CSS 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.Debugging 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.Accessible CSSHow CSS decides whether people can use a page: visible focus, forced-colors mode, reduced motion, scalable text, target size and hiding content properly.CSS performanceWhere CSS really costs time, from render-blocking stylesheets to large-page recalculation, and the fixes: content-visibility, containment and measuring first.Print 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.
CSS foundations
- How 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.
- Selectors 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.
- Pseudo-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).
- Specificity 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.
- Inheritance 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.
- Cascade 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.
- The 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.
- Values, 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.
Layout fundamentals
- Display 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.
- Margin 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.
- Positioning 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.
- Stacking 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.
- Overflow 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.
- Sizing 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.
Typography
- Font 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.
- Variable 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.
- Text 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.
- Fluid 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.
- Text 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.
- Writing 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.
Color and visual effects
- Colors 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.
- Backgrounds 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.
- Borders, 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.
- Box 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.
- Clip-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.
- Transforms and 3DHow transform moves, rotates, scales and skews an element without touching layout, why function order matters, and how perspective makes a card 3D.
Flexbox
- Flexbox 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.
- flex-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.
- Alignment 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.
- Common 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.
Grid
- Grid 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.
- Grid 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.
- Auto-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.
- SubgridHow 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.
- Multi-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.
- Choosing 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.
Responsive design
- Media 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.
- Container 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.
- Viewport 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.
- Intrinsic 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.
- Aspect 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.
- User 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.
Animation and motion
- TransitionsHow 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.
- Keyframe animationsHow @keyframes and the animation properties describe a self-running sequence, including fill modes, direction, negative delays and animating custom properties.
- Animation 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.
- Scroll 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.
- Scroll-driven animationsHow animation-timeline lets scroll position or element visibility drive a normal @keyframes animation, using scroll() and view() timelines and a safe fallback.
- View transitionsHow the View Transitions API snapshots old and new state and animates between them, within a page or across navigations, using view-transition-name.
Modern CSS
- Custom propertiesWhat CSS custom properties are, how they differ from preprocessor variables, how they inherit and cascade, and the patterns that make themes cheap.
- CSS nestingHow native nesting lets a rule contain its own selectors and at-rules, what & means for specificity, and where it differs from Sass nesting.
- :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.
- @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.
- Anchor 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.
- @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.
Architecture and tooling
- CSS 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.
- Sass 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.
- PostCSS and Lightning CSSHow PostCSS and Lightning CSS transform standard CSS at build time (prefixing, lowering syntax, minifying, bundling) and how browserslist shapes the output.
- Utility-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.
- CSS 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.
- Debugging 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.
- Accessible CSSHow CSS decides whether people can use a page: visible focus, forced-colors mode, reduced motion, scalable text, target size and hiding content properly.
- CSS performanceWhere CSS really costs time, from render-blocking stylesheets to large-page recalculation, and the fixes: content-visibility, containment and measuring first.
- Print 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.