Skip to content

CSS Foundations

Visual styling from first principles. Selectors, the box model, color, typography, and the cascade algorithm that governs how styles resolve.

1
How CSS Works
beginner

From bytes to pixels: how browsers parse CSS into the CSSOM, how the cascade algorithm resolves conflicts, and the difference between computed, used, and resolved values.

11 min read
2
Selectors and Specificity
beginner

The complete specificity calculation algorithm, from simple selectors through :where() zero-specificity, :is() specificity forwarding, and the practical strategies for winning specificity battles without !important.

12 min read
3
The Box Model
beginner

Every element is a box: content, padding, border, margin. content-box vs border-box, the complete margin collapse rules, and the edge cases where margins don't collapse.

10 min read
4
Colors, Units, and Values
beginner

When to use px, rem, em, vh, vw — and why the wrong choice creates accessibility failures. Plus the oklch color space and why it's the future of CSS color.

10 min read
5
Typography and Web Fonts
beginner

font-display strategies, FOUT vs FOIT, the size-adjust trick that eliminates layout shift, variable fonts for performance, and the typography system that makes content readable at every size.

11 min read
6
Backgrounds, Borders, and Shadows
beginner

Multiple backgrounds and stacking order, gradient tricks for real production UI, border-image, box-shadow performance implications, and when to use filter vs box-shadow.

11 min read
7
Display and Positioning
beginner

Block, inline, inline-block, flex, grid — the display modes that control how elements participate in layout. Plus static, relative, absolute, fixed, and sticky positioning and how they interact with stacking contexts.

11 min read
8
Overflow and Visibility
beginner

overflow-x vs overflow-y and their interaction, clip vs scroll vs auto, the three ways to hide elements (visibility, display, opacity) and when each is correct for accessibility.

10 min read
9
Pseudo-Classes and Pseudo-Elements
beginner

The modern pseudo-class toolkit: :has() the parent selector, :is() for grouping, :where() for zero-specificity, :not() for exclusion. Plus ::before/::after for generated content.

12 min read
10
CSS Custom Properties
beginner

Custom properties (CSS variables) inheritance, scoping, runtime vs compile-time differences from Sass variables, and building a complete theming system with dynamic switching.

11 min read
11
Quiz: Specificity Battle
beginner

6 tricky 'which rule wins?' questions that test your understanding of the cascade algorithm, specificity calculation, :where() zero specificity, and !important interactions.

7 min read