Exercise 3 solution: a stylesheet driven by a modular scale =========================================================== :root { /* Scale: base 1rem, ratio 1.25 (major third) */ --size-caption: 0.8rem; --size-body: 1rem; --size-lead: 1.25rem; --size-h3: 1.563rem; --size-h2: 1.953rem; --size-h1: 2.441rem; /* Colours: three tones of text, so colour can carry rank */ --ink: #1b1b1f; /* primary text */ --ink-soft: #55555e; /* secondary: lead, captions */ --accent: #b45309; /* used sparingly: kicker, links */ } body { font-family: Georgia, "Times New Roman", serif; font-size: var(--size-body); line-height: 1.55; /* body: comfortable */ color: var(--ink); } .article { max-width: 66ch; margin-inline: auto; padding-inline: 1rem; } .kicker { /* smallest, loudest label: size + caps + tracking + colour */ font-size: var(--size-caption); text-transform: uppercase; letter-spacing: 0.1em; font-weight: 700; color: var(--accent); margin: 0 0 0.5rem; } h1 { font-size: var(--size-h1); line-height: 1.15; /* big text, tight leading */ margin: 0 0 0.75rem; } .lead { font-size: var(--size-lead); color: var(--ink-soft); /* bigger than body but quieter in colour */ margin: 0 0 2rem; } h2 { font-size: var(--size-h2); line-height: 1.2; margin: 2.5rem 0 0.75rem; /* more space ABOVE than below: proximity */ } h3 { font-size: var(--size-h3); line-height: 1.25; margin: 2rem 0 0.5rem; } p { margin: 0 0 1rem; } figcaption { font-size: var(--size-caption); color: var(--ink-soft); margin-top: 0.4rem; } /* Wide screens: scale everything by changing the base only */ @media (min-width: 1200px) { html { font-size: 112.5%; } /* 18px base; every rem value above grows with it */ } How it works ------------ * Every size comes from one variable, so changing the ratio or the base means editing a few lines instead of hunting through the stylesheet. * Rank is carried by more than one tool: size (h1 > h2 > h3 > body), weight (kicker), colour (lead and captions are softer) and space (bigger gap above headings than below). * The wide-screen rule changes only the root size, which is the whole point of using rem: the measure in ch, the headings and the spacing all scale together. * Test it: change --size-h1 to 1.2rem and see how quickly the hierarchy collapses.