← All Exercises

Scale Section Spacing with clamp()

basiccss~15min

Background

clamp() removes spacing breakpoints by interpolating between a minimum and maximum with a preferred viewport unit.

Problem

Style an article section so vertical padding scales from 1.5rem to 4rem with the viewport and the text column stays between 45 and 70 characters wide.

Input

An article section with a heading, paragraphs, and a code block.

Output

CSS with clamped padding and a measured content column.

Sample tests

Sample 1

Input: Viewport width 360px
Expected: padding-block resolves near the 1.5rem minimum while the column fills the width with side padding

Sample 2

Input: Viewport width 1440px
Expected: padding-block stops at 4rem and max-inline-size 65ch centers the column

Your solution

Learning objective

Use clamp with viewport units for fluid spacing and ch units to keep a readable line length.