Responsive design
Interfaces that work across screen sizes and input methods.
Responsive design adapts layout and interaction to phones, tablets and desktops, and to touch, mouse and keyboard. It is more than shrinking things down. Content priorities often change on small screens.
Why it matters for a product engineer
People use the same product on a phone, a tablet and a laptop, with touch, a mouse or a keyboard. Responsive design adapts the layout and the interaction to each. It is more than making things smaller: on a small screen the order of content and the size of targets change too. Almost all of it is code.
How to do it
- Add the viewport meta tag. Without it, a phone renders the page at a desktop width, often about 980 px, and shrinks it.
- Start from the smallest screen and add layout as space allows.
- Let the content choose the breakpoints: add one where the layout starts to look wrong, not at the width of a popular device.
- Size things in relative units, and let images and media scale with their container.
- Make touch targets large enough for a thumb, and do not depend on hover.
- Test on real devices, at real widths such as 390 px, in both orientations.
Common mistakes
- Designing for desktop and squeezing it onto a phone.
- Hiding content on small screens that people need there.
- Breakpoints for specific devices, which break on the next device.
- Text or controls that only work with a mouse.
Example
An agent’s audit of RelievApp asked for every scene to be checked at 390 px in each look. The minimal look needed its own contrast pass: white text over the pale sphere was hard to read, and “Drag up to breathe in” almost disappeared. A layout that works at one width and in one theme is not yet done. (RelievApp in In practice)
The one line every responsive page needs
<meta name="viewport" content="width=device-width1, initial-scale=12">
- 1Match the screenUse the device's width, not a desktop width.
- 2No zoomStart at 100%, so the page is not shrunk to fit.
Without this line, phones lay the page out about 980 px wide and shrink it, and people have to zoom to read.
Reportedweb.dev, Responsive web design basics
Sources: Responsive web design basics (web.dev) ↗ · Learn responsive design (Jeremy Keith, web.dev) ↗
Resources
2- articleStart here
Responsive web design basics ↗
web.dev (Google) · 2019 · 13 minThe essentials in one article, from the viewport tag to media queries.
- courseGo deeper
Learn responsive design ↗
Jeremy Keith (web.dev) · free courseA complete free course on responsive layouts, typography, images and interaction for every screen.