UNIT 20 • STAGE 3 OF 7

The Scale

Replace rigid font sizes with clamp() , fluid type that scales smoothly between any screen size

UNIT
STEP 1

clamp(): Three Values, One Fluid Size

You have used clamp() in the era units since Unit 11, but it was always pre-written. This is the stage where you learn to write it yourself and understand what the three values do.

clamp() takes three arguments: a minimum value, a preferred value, and a maximum value. The browser uses the preferred value as long as it stays between the minimum and maximum. When the preferred would go below the minimum, the minimum wins. When it would go above the maximum, the maximum wins.

// clamp(minimum, preferred, maximum) .era-name {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
}

Read that as: "Never smaller than 1.75rem. Never larger than 2.5rem. Prefers 3.5vw, which is 3.5% of the viewport width." On a 400px phone, 3.5vw is 14px. On a 1400px desktop, 3.5vw is 49px. But the clamp keeps it from going lower than 1.75rem (28px) or higher than 2.5rem (40px). So it scales fluidly between those guardrails.

Why vw works as the preferred value

vw means "viewport width", 1vw is 1% of the screen's width. As the screen gets wider, the font gets bigger. As the screen gets narrower, it gets smaller. That is what makes it "fluid." Combined with clamp's minimum and maximum, you get smooth scaling with guardrails, no breakpoints needed for font size.

STEP 2

Replace Two Media Queries with One clamp()

Look at the .era-number CSS from Stage 2. It uses two separate declarations: font-size: 4.5rem as the default and font-size: 7rem inside a min-width: 768px query. That is two rules to handle one scaling concern.

// Stage 2: two rules, one jump between sizes .era-number { font-size: 4.5rem; }
@media (min-width: 768px) {
  .era-number { font-size: 7rem; }
}
// Stage 3: one clamp(), smooth scaling, no jump .era-number {
  font-size: clamp(3.5rem, 9vw, 7rem);
}

The @media (min-width: 768px) block for .era-number is removed in Stage 3, the clamp() handles everything that the two rules were doing, plus fills in the smooth curve between them.

The width: 140px and text-align: right on the desktop version still need to live in a media query because those are layout decisions, not size decisions. clamp() only handles numeric values.

STEP 3

Add the Eras Section Header

Add a brief header above the eight era entries. This gives the entries section a clear opening and introduces another opportunity to use clamp() on a heading. The header has two parts: a small label and a large heading.

// Section header above the era entries list <div class="eras-header">
  <span class="eras-label">Eight Research Sites</span>
  <h2 class="eras-heading">The Record</h2>
</div>
// Section header CSS, clamp() on the heading, label in small caps .eras-header {
  padding-bottom: 48px;
  border-bottom: 1px solid var(--gold-border);
}
.eras-label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.eras-heading {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: clamp(2rem, 5vw, 3.5rem);  /* fluid heading */
  font-weight: 900;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

Also update the .era-name font-size to use clamp(). The Stage 2 value was a fixed 1.75rem. Replace it with clamp(1.5rem, 3.5vw, 2.25rem) so era names scale fluidly across screen sizes without needing a separate media query.

Stage 3 Complete!

Your typography now scales fluidly at every screen size without fixed breakpoints. Stage 4 brings motion to the era entries: transition and transform: translateX() for hover effects that feel like a well-designed product.

Code Editor
Live Preview