DevPrep
  • Interview Prep
  • Projects
  • Resources
  • Pricing
  • About Us
Submit Question
DevPrep
  • Pricing
  • About Us
Submit Question
← From Beginner to Expert in Fundamentals of Frontend
  • The Box Model
  • Specificity & The Cascade
  • CSS Units Deep Dive
  • Stacking Contexts & Z-Index
  • Flexbox Mastery
  • CSS Grid Mastery
  • Centering, Subgrid & Container Queries
  • CSS Custom Properties & Variables
  • Selectors: :has(), Pseudo-classes & Pseudo-elements
  • Responsive Functions: calc(), clamp(), min(), max()
  • Media Queries & Mobile-First Design
  • Transitions & Animations
  • Transforms, Filters & Clipping
  • CSS Methodologies: BEM, CSS-in-JS & Tailwind
  • Typography, Color Spaces & Dark Mode
  • CSS Performance & Optimization
  • CSS Interview Questions — Part 1
  • CSS Interview Questions — Part 2
← From Beginner to Expert in Fundamentals of Frontend

Typography, Color Spaces & Dark Mode

16 min read
Variable Fontsline-heightOKLCHHSLDark Modeprefers-color-schemeColor SpacesTypography Scale

Typography Systems

Variable Fonts

One font file with adjustable axes (weight, width, slant) instead of separate files for each variant. This reduces HTTP requests and file sizes dramatically.

@font-face {
  font-family: "Inter";
  src: url("/fonts/Inter-Variable.woff2") format("woff2-variations");
  font-weight: 100 900; /* Entire range in one file! */
}

h1 { font-weight: 750; } /* Any weight between 100-900 */

Line Height & Readability

Content TypeOptimal line-height
Body text (14-18px)1.5 - 1.7
Headings (24px+)1.1 - 1.3
Small text (12px)1.6 - 1.8
Code blocks1.5 - 1.6

Color Spaces

Color SpaceSyntaxGamutPerceptual Uniformity
Hex#3b82f6sRGB❌ Poor
RGBrgb(59, 130, 246)sRGB❌ Poor
HSLhsl(217, 91%, 60%)sRGB⚠️ Moderate
OKLCHoklch(63% 0.21 255)P3+✅ Excellent
Display-P3color(display-p3 0.23 0.51 0.96)P3⚠️ Moderate

OKLCH is the recommended color space for 2025+. It produces visually consistent color palettes where changing lightness doesn't shift the hue (unlike HSL).

Dark Mode Implementation

Two approaches:

  1. System preference: @media (prefers-color-scheme: dark)
  2. Manual toggle: [data-theme="dark"] attribute on <html>

Best practice: Support both — respect system preference as default, allow manual override stored in localStorage.

Practice

  • JavaScript
  • DSA
  • Machine Coding
  • System Design

Resources

  • Learning Tracks
  • Articles
  • Roadmaps
  • Compare Concepts
  • Glossary
  • Developer Tools
  • All Questions

Company

  • About
  • Pricing

Legal

  • Privacy Policy
  • Terms of Service
DevPrep

© 2026 DevPrep. All rights reserved.