Sub topic 10
Responsive Breakpoints
This chapter assumes you know the CSS box model, media queries, and how to open DevTools and its device toolbar. It also assumes you can read a design file with more than one frame, such as Figma frames for mobile, tablet and desktop. By now you have measured layout, spacing, type and color at one width. Here you repeat that work at the widths where the layout changes, and at the widths between them, where most responsive bugs hide.
What a breakpoint check is for
A breakpoint is a viewport width at which the CSS changes the layout. Designers usually deliver a few frames, for example 375, 768 and 1280 pixels wide. Users do not have those widths. They have 320, 390, 820, 1024, 1440 and everything in between, and they resize windows.
A responsive check answers two questions:
- At each designed width, does the build match its frame?
- At every other width, does the layout stay usable and consistent with the design's intent?
The first question is a comparison. The second is a judgment, because the design is silent there. You are checking that the layout degrades sensibly, not that it matches a picture that does not exist.
Find the real breakpoints first
Do not assume the build uses the widths in the design. Read them from the code.
- Search the stylesheets for
@media,@container, and tokens or variables that name breakpoints. - In DevTools, open the device toolbar. Chrome shows media query bars above the viewport, and clicking a bar jumps to that width.
- Compare the list with the design's frames and with the breakpoint tokens in the spec.
Record any mismatch. A build that switches layout at 800 pixels when the design says 768 is a finding, even if both look fine at 1280.
/* Typical build: breakpoints expressed as min-width, mobile first */
.card-grid {
display: grid;
grid-template-columns: 1fr;
gap: 16px;
}
@media (min-width: 768px) {
.card-grid {
grid-template-columns: repeat(2, 1fr);
gap: 24px;
}
}
@media (min-width: 1280px) {
.card-grid {
grid-template-columns: repeat(4, 1fr);
gap: 32px;
}
}With min-width, the rule applies at the stated width and above. At exactly 768 pixels the two-column layout is active. Check the boundary yourself, because designers and developers sometimes disagree about whether 768 belongs to "tablet" or "mobile".
Test three kinds of widths
Test at the designed widths, at the edges of each range, and at the extremes.
| Kind of width | Example widths | What you look for |
|---|---|---|
| Designed widths | 375, 768, 1280 | Match against the design frame using the same checks as before |
| Boundary widths | 767, 768, 1279, 1280 | Layout flips exactly where intended, with no half-applied state |
| Just before a break | 700, 1200 | Content is still comfortable right before it reflows |
| Extremes | 320, 1920, 2560 | Nothing overflows at the small end; nothing stretches without limit at the large end |
The widths just before a break are where bugs concentrate. At 1200 pixels a four-column grid may not have kicked in yet, so the two-column layout is stretched across a very wide area. That is often a design gap rather than a code bug, so report it as a question for the designer.
Resize continuously, not only in jumps
Choosing preset device sizes hides problems. Drag the viewport edge slowly from 320 pixels up to 1920 and watch for these failures:
- Horizontal scroll. The page scrolls sideways. Common causes are fixed-width elements, wide images or tables, and
100vwon an element inside a page with a vertical scrollbar. - Text overlap or clipping. Headings collide with images, or buttons spill out of cards.
- Awkward wrapping. A navigation bar wraps to two lines for 50 pixels of width and then collapses to a menu.
- Unbounded stretching. Line length grows past about 75 characters because the content has no maximum width.
- Orphaned spacing. Padding that was designed for desktop stays at 64 pixels on a phone and leaves a thin column of text.
A quick way to find the source of horizontal scroll is to run this in the DevTools console at the width where it happens:
const docWidth = document.documentElement.clientWidth;
const offenders = [...document.querySelectorAll('body *')].filter((el) => {
const rect = el.getBoundingClientRect();
return rect.right > docWidth + 1 || rect.left < -1;
});
console.log(`${offenders.length} elements extend past the viewport`);
offenders.slice(0, 10).forEach((el) => console.log(el));Elements that are intentionally off-screen, such as a closed slide-in menu, will appear in the list. Judge each one.
Compare each designed width properly
At a designed width, set the viewport to the exact frame width and apply the checks from the earlier chapters: layout and spacing, typography, color, assets. Several details are specific to responsive work.
- Typography often changes by breakpoint. A heading may be 32 pixels on mobile and 48 on desktop. Read the computed size at each width. Fluid type using
clamp()will give values between the designed ones, which is correct when the design intent is fluid. Ask the designer if you cannot tell. - Spacing tokens change. Section padding commonly steps from 24 to 48 to 96 pixels. Confirm the token at each width.
- Order can change. Columns stack in a different order on mobile. Check the reading and tab order against the design.
- Elements disappear or move. A secondary link may be hidden on mobile. Confirm that the design hides it, and that hidden content is not still reachable by keyboard.
- Images may be cropped differently. Check that
object-fitandobject-positionkeep the subject visible, and that the design's art direction is followed when it supplies different crops.
Orientation, zoom and container queries
Rotate the device toolbar to landscape. A phone in landscape is wider than 600 pixels but very short, so fixed headers and full-height hero sections can consume the whole screen. Check that content remains reachable.
Layouts built with container queries respond to the width of their parent, not the viewport. A component can look right in a full-width page and wrong in a narrow sidebar at the same viewport width. If the design shows a component in more than one context, test each one.
.product-card-wrapper {
container-type: inline-size;
}
@container (min-width: 480px) {
.product-card {
display: grid;
grid-template-columns: 160px 1fr;
}
}Browser zoom also changes the effective viewport width in CSS pixels. At 200% zoom a 1280-pixel window behaves like a 640-pixel one, so the tablet layout appears. That is expected and is a useful extra test.
Common errors and gotchas
- Missing viewport meta tag. Without
<meta name="viewport" content="width=device-width, initial-scale=1">, mobile browsers render a desktop-width page scaled down. The device toolbar may hide this if it is set to a mobile mode that overrides it. Confirm the tag exists in the source. - Testing only by resizing a desktop window. Windows have a minimum width and scrollbar widths that change the usable area. Use the device toolbar for small widths.
- Fixed pixel heights. A container with
height: 400pxclips text when the layout narrows and the content wraps. Look for clipped text at every width. - Hover-only controls. Interactions that depend on hover do not work on touch. Check that touch layouts expose the same actions.
- Tap targets that are too small. Buttons and links that match the desktop size can be hard to tap. Compare against the design and the platform guidance of roughly 44 by 44 pixels.
- Reporting a diff caused by your setup. Check that zoom is 100% and the device pixel ratio matches the frame before you record a discrepancy.
A repeatable routine
- List the code's breakpoints and the design's frames, and note mismatches.
- For each designed width, set the exact viewport and run the full comparison.
- Test the boundary widths on both sides of each breakpoint.
- Drag the viewport from 320 to the widest design width and watch for overflow, overlap and stretching.
- Test the extremes, landscape orientation and 200% zoom.
- Record each finding with the width at which it occurs.
Always state the width in a report. A finding that says "the cards overlap" cannot be reproduced. One that says "at 820 px wide, the card titles overlap the price" can.
Exercise
A page uses @media (min-width: 768px) to switch from one column to two. The design shows a tablet frame at 768 px wide with two columns. Which four widths should you test around this breakpoint, and what would you report if the page still shows one column at 768 px but two columns at 769 px?
Show answer
Test 767, 768, 769 and a width a little under the next breakpoint, such as 1200 (or at least 767 and 768 as the pair that straddles the break). With min-width: 768px the two-column layout should be active at exactly 768 px. If it only appears at 769 px, the breakpoint is likely written as min-width: 769px or the layout rule uses min-width: 768.02px or a max-width: 768px counterpart that overlaps. Report it with the width (768 px), the observed result (one column), the expected result (two columns, per the tablet frame), and the CSS rule that sets the breakpoint.
Exercise
At 390 px wide, the page scrolls sideways. How do you find the cause, and which result in the console list can safely be ignored?
Show answer
Set the viewport to 390 px, run a script that lists elements whose bounding rectangle extends past document.documentElement.clientWidth, then inspect the first offenders in the Elements panel. Elements that are intentionally off-screen, such as a closed slide-in menu positioned outside the viewport, can be ignored if they do not cause scrolling. Elements such as a wide image, table or a block using 100vw should be reported.