Layout and responsive: Content-width constraints
A width cap keeps long lines readable while inline padding protects small viewports.
Current edit
Understand the pattern
A width cap keeps long lines readable while inline padding protects small viewports.
A width cap keeps long lines readable while inline padding protects small viewports.
Misconceptions to reject
- If the page fits one desktop viewport, no narrower viewport needs checking.
- Hiding all overflow always makes content accessible.
The preview is a sanitized subset, not a full browser compatibility test.
Worked example and expected result
main { max-width: 65ch; }
main { margin-inline: auto; }
main { padding-inline: 1rem; }A width cap keeps long lines readable while inline padding protects small viewports.
Explain it
Apply it elsewhere
Keep the momentum.
Complete the lab, then explain and apply the pattern.
Next: Layout and responsive: Responsive imagesTry an incident drillAnonymous lesson and mastery progress lasts for this session. Sign in to keep synced lesson XP between sessions; mastery stays device-local. No speed bonus, lost lives, or hint penalties.
Keep learning
- 01Layout and responsive: Intrinsic sizingA flexible image can use its natural ratio while fitting its container.Practice
- 02Layout and responsive: Responsive imagesA percentage width responds to the containing block; automatic height preserves aspect ratio.Practice
- 03Layout and responsive: Mobile media queryA max-width media query applies at and below its boundary; the base layout should remain usable without it.Practice