LibraryCSSTypography and Color

Typography and Color

Create a readable type scale and a reusable, contrast-aware color system.

Updated Tested with Modern CSS

Typography establishes rhythm and hierarchy. Color communicates emphasis and state. Both work best as a small system rather than a collection of one-off values.

Set readable defaults

type.css
html { font-size: 100%; }
body {
  font-family: Inter, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.6;
}
h1 {
  font-size: clamp(2.5rem, 7vw, 5rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
}
p { max-width: 68ch; }

Relative units respect user settings. clamp() creates a fluid value with safe minimum and maximum sizes. A readable line length keeps paragraphs easy to track.

Create color tokens

tokens.css
:root {
  color-scheme: light;
  --surface: #ffffff;
  --ink: #211a25;
  --muted: #6d6672;
  --accent: #4c1c62;
  --signal: #f46537;
}

body { background: var(--surface); color: var(--ink); }

Name tokens by role so a theme can change values without rewriting components. Never use color as the only way to communicate an error or selection.

Dark mode

theme.css
@media (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --surface: #151217; --ink: #f2edf3; }
}

Keep this

Use relative, fluid type; limit paragraph width; define semantic color tokens; and test contrast rather than guessing.

Your place is saved on this device.