Sub topic 7
Choosing breakpoints from the content, not from devices
This chapter assumes you can write CSS media queries, know the difference between px, rem, and em, and have set up frames in a design tool such as Figma. Earlier chapters covered the viewport, fluid layouts, and mobile-first min-width queries. Here you decide which widths deserve a breakpoint, and why.
Why device lists fail
A common first approach is to look up popular devices and write one breakpoint per device: 375px for a phone, 768px for a tablet, 1440px for a laptop. This feels precise, but it breaks down for four reasons.
- Device widths change every year. New phones, foldables, and tablets ship with sizes that were not on last year's list.
- A browser window is not a device. Users resize windows, split screens, and zoom. Your layout meets all of these widths.
- The same device reports different widths in portrait and landscape.
- A device list says nothing about your content. A layout can break at 620px even though no popular device has that width.
The layout does not care what hardware is showing it. It only cares how many CSS pixels of width it has. A breakpoint should mark the point where the design stops working.
Find breakpoints by stretching the layout
The content-first method is simple. Build the mobile layout, then widen the browser slowly and watch for the first place where the design looks wrong. That width is a breakpoint candidate.
- Open the page in a browser with the responsive tools turned on.
- Set the width to about 320px and confirm the single-column layout works.
- Drag the width wider, a few pixels at a time.
- Stop when something looks wrong, and note the width.
- Fix it with a media query at that width, then continue widening.
Signs that a breakpoint is needed:
- Lines of body text grow past roughly 75 characters, which makes them hard to read.
- Large gaps open up between elements.
- A single column of cards looks stretched, with images much wider than they are tall.
- Navigation links that fit on one row now have room to spread out. Or, going the other way, they wrap and collide.
- A sidebar could now sit beside the main content without squeezing it.
Measure in the right unit
Write breakpoints in em or rem, not px. In media queries, both em and rem are relative to the browser's default font size, not to any font size you set in CSS. So 48em means 48 times the user's default size, usually 768px.
This matters when a user raises their default text size. Text gets bigger, so fewer characters fit per line. A breakpoint in em shifts to a wider pixel width, and the layout moves to a multi-column arrangement later. That is the correct behavior, because the text needs more room. A breakpoint in px ignores the change, and the columns end up cramped.
| Unit | Responds to user font-size setting | Typical use in a query |
|---|---|---|
| `px` | No | Avoid for layout breakpoints |
| `em` | Yes | Good default |
| `rem` | Yes | Same result as `em` in queries |
/* 768px at the default 16px font size */
@media (min-width: 48em) {
.layout {
grid-template-columns: 1fr 1fr;
}
}Prefer fewer breakpoints
Every breakpoint adds a layout that must be designed, built, and tested. Fluid techniques, such as percentage widths, minmax(), auto-fit, and clamp(), absorb most of the change between widths. Use a breakpoint only for a structural change, such as going from one column to two, or from a menu button to a visible link row.
The auto-fit grid below needs no breakpoint at all. It adds and removes columns as the container changes width.
.cards {
display: grid;
gap: 1rem;
grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
}Many projects end up with two or three breakpoints. A count like that is a result of the process, not a target. A small site may need only one. A dense dashboard may need more.
Name breakpoints and record them as tokens
Once you have found your breakpoints, write them down in one place. Otherwise the CSS says 48em in one file, 47.9em in another, and the design file says 760px.
Name each breakpoint for its role rather than a device. A name like tablet suggests a device and invites the old mistake. Names such as compact, medium, and wide describe layout ranges. The names below are only examples. Use whatever your team agrees on.
| Token | Value | Layout change at this width |
|---|---|---|
| `bp-medium` | `48em` (768px) | Single column becomes two columns |
| `bp-wide` | `80em` (1280px) | Two columns become three, and the content is capped in width |
CSS custom properties cannot be used inside a media query condition. A rule like @media (min-width: var(--bp-medium)) does not work. There are three practical options.
- Keep the values in a design token file and generate the CSS from it with a build tool.
- Use a preprocessor variable, such as a Sass
$bp-medium. - Repeat the literal values and document them in a comment at the top of the stylesheet.
The first option keeps design and code in sync, so it is the best choice if your project already uses a token pipeline. Even with the third option, keep the values in one place and search for them when they change.
/* Breakpoints (keep in sync with design tokens)
bp-medium: 48em
bp-wide: 80em */
.layout {
display: grid;
gap: 1rem;
padding: 1rem;
}
@media (min-width: 48em) {
.layout {
grid-template-columns: 1fr 1fr;
}
}
@media (min-width: 80em) {
.layout {
grid-template-columns: 2fr 1fr 1fr;
max-width: 80rem;
margin-inline: auto;
}
}Match design frames to the breakpoints
In the design tool, make one frame for each layout range, and give each frame a width that sits inside its range. A frame is a sample of the range. It is not the range itself.
| Frame | Example width | Range it represents |
|---|---|---|
| Mobile | 375px | From the smallest supported width up to `bp-medium` |
| Tablet | 768px or 820px | From `bp-medium` up to `bp-wide` |
| Desktop | 1280px or 1440px | From `bp-wide` upward |
Choose frame widths that show the layout working, not at its limit. If the tablet frame is exactly 768px, it sits right on the breakpoint, and it hides the problem of what happens at 767px. It is often more useful to design the frame at a width in the middle of its range, then add a note about what stretches or shrinks within the range.
Also record the behavior between frames. A frame shows one moment, but the page lives across all widths. Annotate each frame with which elements grow, which stay fixed, and which wrap.
Common mistakes
- Adding a breakpoint for every device. This produces many overlapping queries that are hard to maintain. Start from the content and add only what is needed.
- Fixing a problem with a breakpoint when fluid sizing would do. If text or spacing just needs to scale, use
clamp()or relative units. - Using
max-widthandmin-widthranges that overlap or leave gaps. At exactly 48em, amax-width: 48emand amin-width: 48emrule both apply. Pick one direction, usuallymin-width, and stay with it. - Testing only at the breakpoint values. Problems often show up just below a breakpoint, or a long way above the last one. Chapter 14 covers testing between breakpoints.
- Using a different set of values in design and code. Keep one list.
Worked example
Suppose a blog layout has a header, an article, and a sidebar. You build the mobile layout first, with everything stacked in one column.
- At 320px to about 600px, the single column reads well.
- At about 700px, the article text lines reach about 95 characters. That is too long. You could cap the text with
max-width: 65ch, which is a fluid fix, so no breakpoint is needed yet. - At about 840px, the capped article leaves a wide empty strip on the right. The sidebar would fit there. This is a structural change, so it earns a breakpoint at
52.5em, which is 840px. - At about 1400px, the layout looks stretched toward the page edges. You cap the page width with
max-widthand center it. That is also fluid, and again no breakpoint is needed.
Two breakpoint candidates became one real breakpoint. The result is a mobile frame, a wide frame, and an annotation that the article text is capped at 65ch at all widths.
.article {
max-width: 65ch;
}
.page {
display: grid;
gap: 1.5rem;
padding: 1rem;
max-width: 80rem;
margin-inline: auto;
}
@media (min-width: 52.5em) {
.page {
grid-template-columns: minmax(0, 1fr) 16rem;
}
}Exercise
A teammate proposes breakpoints at 375px, 414px, 768px, 1024px, and 1440px because those are common device widths. Give two reasons to question this list, and describe how you would find the breakpoints instead.
Show answer
First, device widths change and a browser window can be any width, so the layout will meet widths not on the list. Second, the list says nothing about where this content breaks, so several of these breakpoints may do nothing, such as 375px and 414px, which would likely have the same single-column layout. To find the real breakpoints, build the mobile layout, widen the window slowly, and note each width where the layout looks wrong, such as overlong lines, large gaps, or cramped navigation. Try fluid fixes first, and add a min-width query in em only for structural changes. Then record the chosen values in one place and match the design frames to them.
Exercise
Why does @media (min-width: 48em) behave better than @media (min-width: 768px) when a user sets a larger default font size in the browser?
Show answer
Media queries measure em against the browser's default font size, not your CSS. When the user enlarges the default size, 48em equals a larger pixel width, so the multi-column layout starts later, once there is enough room for the larger text. The 768px query ignores the setting and switches to columns too early, which leaves the columns cramped.