FIRST PRINCIPLES CURRICULUM · CSS LAYOUT ENGINES · LIVE PREVIEWS IN EVERY LESSON

CSS Architecture &
Modern Layout Engine.

An engineering masterclass deconstructing browser layout engines, the CSS box model, Flexbox 1D axes, 2D Grid & Subgrid, Cascade Layers (@layer), and Container Queries. Featuring live interactive visual previews and compiler drills in every lesson.

01/THE BOX MODEL & INTRINSIC SIZING
LAYOUT ENGINE LEVEL 0

In CSS, every visible element generates a rectangular box consisting of four concentric areas: Content, Padding, Border, and Margin. The fundamental architectural decision of every design system is setting box-sizing: border-box.

Code Specification: Content-Box vs Border-Box
box-model.css
/* 1. Universal modern reset (Standard) */
*, *::before, *::after {
  box-sizing: border-box;
}

/* 2. Demonstration: Box with width: 300px + padding: 24px + border: 4px */
.modern-box {
  box-sizing: border-box;
  width: 300px;
  padding: 24px;
  border: 4px solid #A795D4;
  background: #1A1A22;
  /* Total rendered width on screen = exactly 300px! */
}
Contrasting default content-box with modern border-box sizing.
Live Browser Visualizer: The Box ModelLIVE RENDERED PREVIEW
Margin Area (External Spacing)
Border Area (4px #A795D4)
Padding Area (24px Inner Space)
Content Box (Rendered Text)
Architectural Invariant: Under border-box, padding and border are subtracted inward from the declared width, preventing layout overflow bugs.
02/MODERN FLEXBOX 1D LAYOUT ENGINE
AXIS ALIGNMENT MATRIX

Flexbox is optimized for one-dimensional layouts along either a horizontal row or a vertical column. It establishes a Main Axis (governed by justify-content) and a Cross Axis (governed by align-items).

Interactive Flexbox Playground (Adjust Controls to See Live Preview)REAL-TIME DOM UPDATE
Rendered Result: display: flex; flex-direction: row; justify-content: flex-start; align-items: stretch; gap: 16px;
Item 01 (flex: auto)
Item 02 (flex: auto)
Item 03 (flex: auto)
03/2D CSS GRID & SUBGRID SYSTEMS
TWO-DIMENSIONAL MATRIX

Unlike Flexbox which handles items along a single axis, CSS Grid coordinates elements across simultaneous rows and columns. Using fractional units (1fr) and minmax(), Grid builds fluid layouts with zero calculation hacks.

Grid Columns:
Gap: 16px
Rendered Result: display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
[REACT]

React 18 Concurrency

Cooperative multitasking and interruptible fiber priority.

[TYPESCRIPT]

TypeScript satisfies

Preserving literal types with strict contract validation.

[JAVASCRIPT]

V8 Engine Memory

Scavenger minor GC and Old Space mark-sweep mechanics.

[CSS]

CSS Subgrid Systems

Nested grid track inheritance across card layouts.

04/CASCADE LAYERS (@layer) SPECIFICITY ARCHITECTURE
CASCADE CONTROL
Code: Declaring Explicit Layer Precedence
cascade-layers.css
/* 1. Explicit layer priority order (Later layers win!) */
@layer reset, base, components, utilities;

@layer base {
  /* High selector specificity (0, 2, 1), but low layer priority */
  article.post ul > li a {
    color: #A8A49C;
    text-decoration: underline;
  }
}

@layer components {
  /* Low selector specificity (0, 1, 0), but WINS because it's in higher layer! */
  .btn-accent {
    color: #A795D4;
    text-decoration: none;
    font-weight: 600;
  }
}
Eliminating specificity wars using standard @layer blocks.
Live Browser Preview: Layer Precedence Victory

The link below has high selector specificity in @layer base, but is overridden by a single class in @layer components without needing !important:

The Specificity Rule: Within a single layer, standard specificity applies. Across layers, the layer declaration order always takes precedence over selector specificity.
05/POSITIONING & STACKING CONTEXTS
Z-INDEX MECHANICS
Code: Stacking Isolation and Sticky Bounds
stacking-context.css
/* 1. Prevent child z-indexes from leaking into global page */
.modal-wrapper {
  position: relative;
  isolation: isolate; /* Creates fresh stacking context! */
}

/* 2. Sticky navigation pinned within parent bounds */
.sticky-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(12, 12, 14, 0.95);
  backdrop-filter: blur(8px);
}
Creating isolated stacking contexts using isolation: isolate.
Live Browser Preview: Sticky Header in Action
STICKY NAV (top: 0)PINNED

Scroll down inside this box to witness the header pin smoothly to the top of the container.

A sticky element behaves like relative position until its threshold (top: 0) is reached, at which point it pins within its parent element’s bounding box.

When the parent scrolls completely out of view, the sticky element scrolls off with it.

End of scrollable container.

06/CONTAINER QUERIES & FLUID CONTAINER UNITS
COMPONENT RESPONSIVENESS
Code: Component Responding to Container Dimensions
container-query.css
.card-host {
  container-type: inline-size;
}

.responsive-card {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.5rem;
}

@container (min-width: 380px) {
  .responsive-card {
    flex-direction: row;
    align-items: center;
  }
}
Using @container (min-width: 380px) to switch layout.
Live Browser Preview: Resizing Container Demo
In 280px Narrow Container (Stacked View):
FA
Narrow Sidebar Card
In 420px Wide Container (Horizontal Row View):
FA
Horizontal Layout Automatically Activated
07/60FPS GPU ANIMATION & COMPOSITOR ARCHITECTURE
COMPOSITOR THREAD
Code: Zero-Reflow GPU Compositor Animation
gpu-animation.css
/* 1. Offload animation entirely to GPU thread */
.gpu-card {
  will-change: transform;
  transform: translateZ(0); /* Promotes layer to GPU */
  transition: transform 250ms cubic-bezier(0.16, 1, 0.3, 1),
              box-shadow 250ms ease;
}

.gpu-card:hover {
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 12px 32px rgba(167, 149, 212, 0.18);
}
Transitioning transform and opacity exclusively on the compositor thread.
Live Browser Preview: Hover Over the Card
[GPU COMPOSITOR THREAD ACTIVE]

Hover Over This Panel

Notice how buttery smooth this animation feels. Because it only transitions transform, the browser avoids paint and layout recalibration phases.

08/RELATIONAL SELECTORS: :has(), :is(), :where()
THE PARENT SELECTOR
Code: Relational Parent & Sibling Queries
relational-selectors.css
/* 1. Style parent card when its child checkbox is checked */
.pricing-card:has(input[type="checkbox"]:checked) {
  border-color: #A795D4;
  background: rgba(167, 149, 212, 0.08);
  box-shadow: 0 0 24px rgba(167, 149, 212, 0.15);
}

/* 2. Zero-specificity utility grouping with :where() */
:where(article, section, aside) h2 {
  font-family: 'Space Grotesk', sans-serif;
  letter-spacing: -0.04em;
  /* Specificity = (0, 0, 0)! Easily overridden anywhere */
}

/* 3. Forgiving selector grouping with :is() */
:is(header, footer, nav) a:hover {
  color: #FFFFFF;
}
Using :has() to style parent containers based on child input states.
Live Browser Preview: Click the Checkbox Below
[PARENT DEFAULT STATE]$29 / mo

Notice how toggling this inner child input directly transforms the outer parent container's borders, background tint, and aura. This eliminates the need for JavaScript class toggles.

The :has() Superpower: Enables styling preceding siblings and parent elements based on child state or subsequent siblings.
09/NATIVE CSS ANCHOR POSITIONING API
ZERO-JS POPUPS & TOOLTIPS
Code: Tethering Floating Elements to Anchors
anchor-positioning.css
/* 1. Name the trigger anchor */
.deploy-trigger {
  anchor-name: --deploy-btn;
}

/* 2. Position tooltip relative to the anchor */
.deploy-tooltip {
  position: absolute;
  position-anchor: --deploy-btn;
  bottom: anchor(top); /* Align bottom of tooltip to top of button */
  left: anchor(center); /* Center horizontally on button */
  transform: translateX(-50%);
  margin-bottom: 8px;
}
Native anchor binding without Popper.js or bounding rect math.
Live Browser Preview: Click or Hover Trigger
[ANCHORED]: --deploy-btn // bottom: anchor(top)
The Anchor Advantage: Tooltips stay anchored even when the parent scrolls or resizes, rendering in the top layer without clipping overflow issues.
10/SCROLL-DRIVEN ANIMATIONS (scroll() & view())
DECLARATIVE SCROLL TIMELINES
Code: Declarative Scroll Timeline Progress Bar
scroll-driven.css
/* 1. Keyframes scaling from 0% to 100% width */
@keyframes growProgress {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}

/* 2. Bind animation directly to scroll progress */
.scroll-tracker {
  transform-origin: left;
  animation: growProgress auto linear;
  animation-timeline: scroll(); /* Tracks document or container scroll! */
}
Piping scroll progress directly to CSS animation keyframes.
Live Browser Preview: Scroll Down Inside the Container
SCROLL PROGRESS: 0%animation-timeline: scroll()

Scroll down through this text block to watch the purple reading progress indicator fill dynamically at the top.

In modern CSS, this entire feature requires zero JavaScript: no scroll event listeners, no requestAnimationFrame loops, and no layout recalculation jank.

The browser compositor samples scroll offset hardware directly on the compositor thread.

100% scroll progress reached at bottom of box.

11/PERCEPTUAL OKLCH COLOR SPACE & color-mix()
WIDE-GAMUT COLOR SYSTEMS
Code: Perceptual Uniformity & Dynamic Mixing
modern-colors.css
:root {
  /* OKLCH: Lightness (0-1), Chroma (0-0.4), Hue (0-360) */
  --brand-violet: oklch(0.72 0.16 295);
  --brand-surface: oklch(0.18 0.02 260);

  /* Dynamically mix tints without declaring separate hex codes */
  --tint-subtle: color-mix(in oklch, var(--brand-violet) 20%, transparent);
  --border-strong: color-mix(in oklch, var(--brand-violet) 60%, black);

  /* Native theme switching */
  --bg-adaptive: light-dark(#FFFFFF, #0C0C0E);
}
Defining predictable accessible palettes with oklch and color-mix.
Live Browser Preview: Dynamic OKLCH Color Mixingcolor-mix ratio: 40%
0% (Transparent)50% Balanced100% Solid Violet
color-mix(in oklch, var(--violet) 40%, transparent)
Perceptually uniform brightness across all hues.
12/DISCRETE TRANSITIONS & @starting-style
NATIVE ENTRY/EXIT ANIMATIONS
Code: Animating Elements from display: none
starting-style.css
/* Enable discrete property transitions */
.entry-card {
  transition: opacity 300ms ease,
              transform 300ms ease,
              display 300ms allow-discrete;
}

/* Initial state when element first enters the DOM */
@starting-style {
  .entry-card {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* Hidden state */
.entry-card.is-hidden {
  display: none;
  opacity: 0;
}
Transitioning display and opacity without JavaScript timeouts.
Live Browser Preview: Test Entry Animation
@starting-style // SMOOTH ENTRY

Natively animated entry transition without flash of unstyled content or JS timeouts!

13/CSS SCOPING WITH @scope & DONUT SCOPING
ISOLATED SELECTOR BOUNDARIES
Code: Native Component Scoping without CSS Modules
scoped-component.css
/* 1. Root Scoping: Styles only match elements inside .media-card */
@scope (.media-card) {
  h3 {
    color: #F5F4F0;
    font-size: 1.25rem;
  }
  p {
    color: #A8A49C;
  }
}

/* 2. Donut Scoping: Styles apply from .media-card down TO .slot-unscoped */
@scope (.media-card) to (.slot-unscoped) {
  /* This p is styled, but any p inside .slot-unscoped is untouched! */
  p {
    margin-bottom: 1rem;
    font-family: 'Space Grotesk', sans-serif;
  }
}
Scoping styles to .component-card while excluding nested .slot-unscoped content (Donut Scoping).
Live Browser Preview: Donut Scoping in Action@scope to (.slot-unscoped)
OUTER: .media-card (SCOPED ROOT)STYLED VIA @scope

Scoped Card Header

This paragraph is styled by the @scope block with violet accents and custom line spacing.

THE DONUT HOLE: .slot-unscoped (EXCLUDED FROM PARENT STYLES)

Nested slotted user content here escapes parent card rules cleanly, eliminating unwanted CSS inheritance bugs!

The Donut Architecture: Allows design systems to style a wrapper component without accidentally overriding the typography or buttons of child components slotted inside it.
14/CSS VIEW TRANSITIONS API
MORPHING DOM STATES
Code: Shared Element Morphing Across States
view-transitions.css
/* 1. Tag element with a unique transition name */
.hero-thumbnail {
  view-transition-name: active-article-hero;
}

/* 2. Configure transition duration on the pseudo-elements */
::view-transition-old(active-article-hero),
::view-transition-new(active-article-hero) {
  animation-duration: 350ms;
  animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 3. In standard MPAs: enable cross-document view transitions */
@view-transition {
  navigation: auto; /* Zero-JS page morphing between HTML routes! */
}
Binding elements to view-transition-name to animate size and position automatically.
Live Browser Preview: Click to Morph Element
view-transition-name: active-article-hero[COMPACT STATE]

RSC Architecture Overview

Click to trigger native element morphing transition.

15/THE NATIVE POPOVER API & TOP-LAYER
ZERO-JS LIGHT DISMISS
Code: HTML Popover Attribute & ::backdrop
native-popover.html
<!-- 1. Trigger button with popovertarget -->
<button popovertarget="telemetry-popover">
  Inspect Telemetry Menu
</button>

<!-- 2. Popover rendered into browser Top Layer (above all z-index!) -->
<div id="telemetry-popover" popover="auto">
  <h3>Active Cluster Telemetry</h3>
  <p>V8 Heap: 48.2MB // GC Status: Optimal</p>
</div>

/* 3. CSS styling of top-layer backdrop */
[popover]::backdrop {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}
Native Top Layer popover with automatic click-outside light dismiss.
Live Browser Preview: Click to Open Popoverpopover="auto"
The Popover Advantage: Built-in light-dismiss (closes automatically when clicking anywhere outside or pressing Esc) with zero event listeners.
16/CSS SUBGRID FOR MULTI-ROW CARD ALIGNMENTS
TRACK INHERITANCE
Code: Inheriting Parent Grid Rows with subgrid
subgrid-alignment.css
/* 1. Parent Grid defines rows: header, body, footer */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: auto 1fr auto;
  gap: 1.5rem;
}

/* 2. Child card spans 3 rows and uses subgrid track inheritance */
.card {
  grid-row: span 3;
  display: grid;
  grid-template-rows: subgrid; /* All headers & footers align across cards! */
}
Subgrid links internal card rows to parent grid tracks.
Live Browser Preview: Subgrid vs Flex Alignment
[SPEC 01]
Short Title

Brief summary text.

[SPEC 02]
Very Long Multi-Line Heading Wrapping Two Lines

Longer descriptive paragraphs causing vertical card expansion.

The Alignment Difference: With subgrid, card action buttons lock to identical horizontal baselines regardless of headline wrapping.
17/LAYOUT CONTAINMENT & content-visibility: auto
ZERO-JS DOM VIRTUALIZATION
Code: Skipping Off-Screen Layout & Paint
content-visibility.css
/* 1. Skip rendering off-screen DOM nodes automatically */
.feed-item {
  content-visibility: auto;
  contain-intrinsic-size: 0 140px; /* Estimates height to prevent scrollbar jumping! */
}

/* 2. Strict layout & paint containment */
.contained-module {
  contain: layout paint;
}
Browser skips rendering off-screen elements while reserving height.
Live Telemetry: Rendering Budget Optimization80% RENDER TIME SAVED
Virtual Feed Nodes:500 Elements
Off-Screen Paint Work:SKIPPED BY BROWSER
In-Page Search (Ctrl+F):PRESERVED NATIVELY
Performance Impact: Unlike JavaScript virtualizers that delete nodes from the DOM, content-visibility: auto leaves nodes in the DOM so browser search (Ctrl+F) and accessibility screen readers still locate text.
18/FLUID TYPOGRAPHY & clamp() MATHEMATICS
CONTINUOUS SCALING WITHOUT BREAKPOINTS
Code: Fluid clamp() Curves & Mathematical Functions
fluid-math.css
:root {
  /* clamp(MIN, PREFERRED_CURVE, MAX) */
  --title-fluid: clamp(1.5rem, 1rem + 2.5vw, 3.5rem);
  --padding-fluid: clamp(1rem, 2vw, 3rem);

  /* Modern round() snaps values to 8px pixel grids */
  --snapped-gap: round(nearest, 2.5vw, 8px);
}

h1 {
  font-size: var(--title-fluid);
  letter-spacing: -0.04em;
}
Fluid font scaling with clamp(min, preferred, max) and round().
Live Interactive Preview: Drag Width SliderWidth: 600px
320px (Mobile)600px (Tablet)900px (Desktop)
Fluid Headline Scaling
Computed Font: 26.0px
19/CSS GRID DENSE PACKING & AUTO-FLOW
MASONRY BACKFILLING
Code: Backfilling Holes with grid-auto-flow: dense
grid-dense.css
/* 1. Container enabling dense packing algorithm */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-flow: dense; /* Backfills empty holes! */
  gap: 1rem;
}

/* 2. Asymmetric items spanning multiple tracks */
.wide-item {
  grid-column: span 2;
}
.tall-item {
  grid-row: span 2;
}
Instructing the grid placement algorithm to backfill earlier empty spaces.
Live Browser Preview: Dense Packing vs Sparse Flow
#01 (1x1)
#02 (Wide 2x1 Span)
#03 (1x1)
#04 (Dense Backfilled!)
#05 (1x1)
#06 (2x1)
The Dense Rule: Under dense, if an asymmetric item skips a hole because it's too large, subsequent smaller items automatically fill the preceding gap, preventing empty visual holes.
20/INTRINSIC SIZING & MODERN aspect-ratio
ASPECT RATIO ARCHITECTURE
Code: Native aspect-ratio & fit-content Sizing
aspect-ratio.css
/* 1. Native responsive video / card container */
.video-frame {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #131318;
}

/* 2. Intrinsic content keywords */
.badge-label {
  width: fit-content; /* Shrinks to text without wrapping */
}
.sidebar-panel {
  min-width: min-content; /* Minimum width before overflow */
  max-width: max-content; /* Maximum width without soft-wrapping */
}
Declaring exact aspect ratios without legacy padding-top hacks.
Live Browser Preview: aspect-ratio Switcheraspect-ratio: 16/9
[CONTAINER INTRINSIC BOX: 16/9]

Guarantees zero Cumulative Layout Shift (0 CLS) during media load.

21/CSS HOUDINI TYPED PROPERTIES (@property)
INTERPOLATABLE VARIABLES
Code: Registering Typed Custom Properties
houdini-property.css
/* 1. Register typed custom property with syntax */
@property --gradient-angle {
  syntax: '<angle>';
  inherits: false;
  initial-value: 0deg;
}

/* 2. Keyframe animation interpolating the angle */
@keyframes spinGradient {
  to { --gradient-angle: 360deg; }
}

/* 3. Apply animated conic gradient border */
.glowing-border {
  background: conic-gradient(
    from var(--gradient-angle),
    #A795D4, #4305B9, #5709F3, #A795D4
  );
  animation: spinGradient 4s linear infinite;
}
Registering angle syntax to enable smooth conic gradient rotation.
Live Browser Preview: Rotating Conic BorderAngle: 45°
@property --gradient-angle: <angle>

Houdini gives CSS custom properties type information, allowing browser animation engines to interpolate values smoothly.

22/ADVANCED MASKING & CLIPPING (mask-image, clip-path)
ALPHA FADING & POLYGONS
Code: Alpha Fade Masks and Geometric Polygonal Cuts
masks-clipping.css
/* 1. Alpha gradient fade on long content */
.scroll-fade {
  mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
}

/* 2. Cyberpunk cut corners via polygon coordinates */
.tech-badge {
  clip-path: polygon(
    0 0,
    calc(100% - 12px) 0,
    100% 12px,
    100% 100%,
    12px 100%,
    0 calc(100% - 12px)
  );
}
Non-destructive fading with mask-image and angled corners with clip-path.
Live Browser Preview: Alpha Fade Mask SliderFade Point: 60%
clip-path: polygon(...)

Alpha Gradient Masking

Notice how the bottom text gently dissolves into transparency without requiring overlay DOM gradient divs. The element underneath remains visible through the mask.

Additional trailing lines dissolve into transparency according to the mask slider setting above.

23/CSS BACKDROP FILTERS & FROSTED GLASS
REAL-TIME BLUR SHADERS
Code: Glassmorphism Shaders & Saturation
backdrop-filter.css
/* 1. Frosted glass panel blurring content underneath */
.glass-panel {
  background: rgba(19, 19, 24, 0.7); /* Semi-transparent base */
  backdrop-filter: blur(12px) saturate(160%);
  -webkit-backdrop-filter: blur(12px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* 2. Dark mode system synchronization */
:root {
  color-scheme: dark;
}
Hardware-accelerated background blurring using backdrop-filter.
Live Browser Preview: Backdrop Blur Intensityblur(12px)
TEXT_UNDERNEATH_BLURGEOMETRIC_MATRIX
backdrop-filter: blur(12px)

The background text and gradients are blurred natively by the GPU shader pipeline.

24/CSS COUNTERS & HIERARCHICAL NUMBERING
DYNAMIC AUTOMATED NUMBERING
Code: Nested Multi-Level Outline Numbering
css-counters.css
/* 1. Reset root counter */
.doc-outline {
  counter-reset: chapter;
}

/* 2. Increment chapter on each top item */
.doc-outline > li {
  counter-increment: chapter;
}
.doc-outline > li::before {
  content: "CH " counter(chapter, decimal-leading-zero) ". ";
  color: #A795D4;
  font-weight: 600;
}

/* 3. Nested sub-list inherits and appends child numbers */
ol ol {
  counter-reset: subitem;
}
ol ol > li {
  counter-increment: subitem;
}
ol ol > li::before {
  content: counter(chapter) "." counter(subitem) " ";
  color: #F5F4F0;
}
Generating nested section numbers (e.g. 1.1, 1.2.1) with counters().
Live Browser Preview: Nested CSS Counter Output
CH 01. Document Ancestry
1.1 DOCTYPE standards mode activation
1.2 Metadata registry configuration
CH 02. Semantic Landmark Flow
2.1 Top-level main element uniqueness
2.2 Accessible navigation labeling
Zero JavaScript: If you reorder, delete, or insert chapters, CSS automatically recalculates all indices on the next frame.
25/PRINT STYLESHEETS & PAGED MEDIA ARCHITECTURE
PDF & HARDCOPY FORMATTING
Code: Clean Print & Page-Break Protection
print-styles.css
@media print {
  /* 1. Hide interactive chrome */
  header, footer, nav, button, .no-print {
    display: none !important;
  }

  /* 2. Prevent card from breaking across pages */
  article, .spec-card, table {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  /* 3. Expand URLs into readable text */
  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 85%;
    color: #444;
  }

  /* 4. Optimize page margins */
  @page {
    margin: 2cm;
    size: A4 portrait;
  }
}
Formatting documents for PDF export and clean printer rendering.
Live Browser Preview: Simulated Print Sheet (A4)
FAISAL ASKARI TECHNICAL HUBPAGE 1 OF 1

React 18 Concurrency Architecture

Printed output automatically strips dark mode backgrounds, inverts text to ink-saving pure black on white, hides navigation menus, and prevents table splitting.

Reference: https://faisalaskari.top/articles/react-18-concurrency-and-transitions
26/VARIABLE FONTS & OPENTYPE TABULAR NUMERALS
TYPOGRAPHIC AXES
Code: Continuous Weight Axes & font-feature-settings
variable-fonts.css
/* 1. Continuous font weight variation (100 to 900 without step jumps) */
.dynamic-text {
  font-variation-settings: 'wght' 650, 'opsz' 14;
}

/* 2. OpenType Tabular Numerals: All numbers share identical width! */
.numeric-data {
  font-feature-settings: 'tnum' 1, 'zero' 1;
  /* Columns never jitter or wobble when counters increment! */
}
Controlling variable font weight axes and enabling tabular figures.
Live Browser Preview: Continuous Weight AxisWeight: 600
Continuous Variable Weight: 600
Tabular Figures: $1,420.90 vs $9,811.23 (Aligned)
27/TOUCH INTERACTIONS & OVERSCROLL CONTAINMENT
MOBILE GESTURE BOUNDARIES
Code: Mobile Touch Controls & Scroll Chaining Defense
touch-interactions.css
/* 1. Eliminate 300ms double-tap zoom delay */
button, a {
  touch-action: manipulation;
}

/* 2. Prevent scroll chaining: scrolling inside drawer does NOT bounce body */
.mobile-drawer {
  overscroll-behavior-y: contain;
  overflow-y: auto;
}

/* 3. Pass-through transparent click overlays */
.click-through-layer {
  pointer-events: none;
}
Eliminating 300ms tap delay and preventing mobile pull-to-refresh bounces.
Live Browser Preview: overscroll-behavior: contain
[CONTAINED SCROLL CONTAINER]

Scroll up and down inside this box. When you hit the top or bottom edge, scrolling is contained—the outer browser page will never bounce or scroll chain.

Essential for mobile bottom-sheets, modal dialogues, and sidebars.

End of contained scroll zone.

28/CSS LOGICAL PROPERTIES & INTERNATIONALIZATION
WRITING-MODE INDEPENDENCE
Code: Flow-Relative Dimensions & Margins
logical-properties.css
/* Physical (Legacy - Breaks in RTL!): */
.card-old {
  margin-left: 24px;
  padding-top: 16px;
  width: 100%;
}

/* Logical (Modern - Works in LTR, RTL, and Vertical text!): */
.card-modern {
  margin-inline-start: 24px; /* Automatically flips in RTL! */
  padding-block: 16px;
  inline-size: 100%; /* Replaces width */
}
Replacing physical left/right with flow-relative inline/block.
Live Browser Preview: LTR vs RTL Layout Flip
DIR: LTR (LEFT-TO-RIGHT)
Flow-Relative Indentation

The border and margins automatically flip sides based on text direction with zero overrides!

29/HANDS-ON INTERACTIVE CSS DRILLS
LIVE STYLESHEET COMPILER & VALIDATOR

Drill 01: Universal Border-Box & Margin Collapse Elimination

Difficulty: Beginner

Establish modern reset rules. Configure universal border-box sizing across all elements and pseudo-elements, normalize default margins on headings and paragraphs, and ensure smooth scroll behavior.

Verification Requirements Checklist:
  • •Apply box-sizing: border-box to *, *::before, *::after
  • •Remove margin: 0 on body, h1, h2, h3, p
  • •Set min-height: 100vh on body with line-height: 1.5
CSS Stylesheet Editor
Live Browser Sandbox Rendering

CSS Modern Box Reset

Without border-box, padding expands the box outside its declared width.