Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 9.1 — Responsive Design Principles
CSS · Example 2 of 4

Mobile first: one column, more columns when there is room

In the narrow preview you see one column. Open the full-screen editor or widen your window: at 30rem (480px) it becomes two columns, at 50rem (800px) three.

Responsive design means one page whose layout adapts to any screen: start with the small-screen layout (mobile first), size things fluidly instead of in fixed pixels, and add the viewport meta tag so phones show the page at its real width.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 6 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write the HTML <head> lines and CSS for a page wrapper that fills a phone with a 16px gutter and stops at 720px wide, centred, on larger screens.

02

Rewrite this desktop-first CSS as mobile first: .nav { display: flex; } @media (max-width: 599px) { .nav { display: block; } }.

03

Make a list of product cards that shows as many columns as fit, each at least 200px wide, without any media query and without overflowing a 180px-wide screen.

Explain it without notes

01

What is responsive design, and what are its main ingredients?

02

What does the viewport meta tag do, and what happens without it?

03

What does "mobile first" mean in CSS, and why is it usually preferred?

04

How should you choose breakpoints?

Mobile first: one column, more columns when there is room

Preview

Press Run to see the page.

Console

Nothing logged yet.