CSS Lab Examples
Twenty standalone demo pages that follow the track's lesson order, grouped by phase. Each demo is a
complete, commented HTML file with embedded styles. Every row has two links:
View code opens the source in the code viewer; Preview opens the
rendered page in a new tab. Change one declaration in the source, then reload the preview — that loop is
where the learning happens.
Foundations
The syntax, selectors, cascade, and values every later demo assumes.
| # | Description | View code | Preview |
|---|---|---|---|
| 1 | Rule anatomy — selectors, declarations, comments, a dropped typo | View | Preview |
| 2 | Selector lab — type, class, ID, compound, and attribute selectors | View | Preview |
| 3 | Combinators — descendant, child, and sibling relationships | View | Preview |
| 4 | Cascade order — competing rules resolved step by step | View | Preview |
| 5 | Specificity ladder — weights from :where() to inline style | View | Preview |
| 6 | Custom properties — declaration, inheritance, and subtree overrides | View | Preview |
| 7 | Units and functions — rem, ch, calc, clamp, min, max at work | View | Preview |
| 8 | Color spaces — hex, rgb, hsl, oklch and color-mix side by side | View | Preview |
Box and text
The box model and typography decisions that every interface inherits.
| # | Description | View code | Preview |
|---|---|---|---|
| 9 | Box model — content-box vs border-box rendered widths | View | Preview |
| 10 | Margin collapse — sibling and parent-child collapsing, and the gap fix | View | Preview |
| 11 | Typographic scale — measure, leading, and hierarchy | View | Preview |
| 12 | Fluid type — clamp() with floors and ceilings, resized live | View | Preview |
Layout
Flow, positioning, and the two layout systems.
| # | Description | View code | Preview |
|---|---|---|---|
| 13 | Flow and display — block, inline, inline-block behavior | View | Preview |
| 14 | Positioning — static, relative, absolute, fixed, sticky panels | View | Preview |
| 15 | Flexbox patterns — toolbar, media object, centering, equal cards | View | Preview |
| 16 | Grid patterns — auto-fit card wall, template-area page shell | View | Preview |
Responsive and quality
Mobile-first layouts, motion with manners, and accessibility in practice.
| # | Description | View code | Preview |
|---|---|---|---|
| 17 | Mobile-first layout — base styles plus additive min-width queries | View | Preview |
| 18 | Animations — transitions, keyframes, and prefers-reduced-motion | View | Preview |
| 19 | Accessible styling — focus, contrast, target size, screen-reader utilities | View | Preview |
| 20 | Print styles — a @media print stylesheet for articles | View | Preview |
How to use them. The demos need nothing but a browser — each file is self-contained. In
the code viewer, change one declaration and study what you would expect to change; in the preview,
verify. Larger multi-file study projects are on the
Study Projects page.