Lab 09: CSS Typography
Overview
Step 1: Variable Fonts
/* @font-face for variable font */
@font-face {
font-family: 'Inter';
src: url('/fonts/Inter.var.woff2') format('woff2 supports variations'),
url('/fonts/Inter.var.woff2') format('woff2'); /* fallback */
font-weight: 100 900; /* range for variable font */
font-style: normal;
font-display: swap;
}
/* Standard axes (registered): */
/* wght — weight: 100 to 900 */
/* wdth — width: condensed to expanded */
/* ital — italic: 0 or 1 */
/* slnt — slant: -90 to 90 degrees */
/* opsz — optical size */
/* font-variation-settings: 'axis' value */
.heading {
font-family: 'Inter', sans-serif;
font-variation-settings:
'wght' 800, /* bold */
'opsz' 32; /* optical size for display text */
}
.body-text {
font-variation-settings:
'wght' 400,
'opsz' 14;
}
/* Prefer font-weight for standard axes (it maps to wght) */
h1 { font-weight: 800; } /* browser maps to wght 800 */
p { font-weight: 400; }
/* Custom axes (use 4-char uppercase tags) */
.display {
font-variation-settings: 'GRAD' 150, 'SOFT' 0;
}
/* Animate variable font */
@keyframes font-pulse {
0%, 100% { font-variation-settings: 'wght' 400; }
50% { font-variation-settings: 'wght' 800; }
}
.animated-text {
animation: font-pulse 2s ease-in-out infinite;
}Step 2: font-display
Step 3: System Font Stacks
Step 4: Fluid Type Scale with clamp()
Step 5: text-wrap and Line Control
Step 6: font-optical-sizing
Step 7: Letter Spacing & Advanced Features
Step 8: Capstone — Type Scale Generator
Summary
Property
Values
Purpose
Last updated
