Made by Dhawal Made by Dhawal
Live demo

How Responsive Breakpoints Actually Work (With a Live Demo)

One column on your phone, four on your desktop. Here's how CSS Grid and a few media queries make the switch, and the one rule about order that trips everyone up.

Told by Vishwa, with Kai asking the questions

Vishwa: Drag the edge of your browser window, Kai. Watch what the layout does, and watch what you say.

Okay, I'm watching…

How does a website go from one column on your phone to four on your desktop? There's no magic and no device detection. Just CSS Grid, a few media queries, and one rule about order that trips up almost everyone.
Interactive · drag the handle
Your viewport — live — · —

↔ Drag the window edge. That's the whole pitch.

The one-sentence version

A breakpoint is the width at which your CSS swaps one layout rule for another. Below 640px: one column. At 640px or wider: two. That's the whole idea; everything else is detail.

Kai's first attempt

KaiEasy. I'll look up the iPhone width, the iPad width and the laptop width, and write a rule for each device.

kai-breakpoints.css
/* one rule per device… */
@media (max-width: 1024px) {
.cards {
grid-template-columns: repeat(3, 1fr);
}
}
/* iPad */
@media (max-width: 768px) {
.cards {
grid-template-columns: repeat(2, 1fr);
}
}
/* iPad mini */
@media (max-width: 430px) {
.cards {
grid-template-columns: 1fr;
}
}
It works on the three devices Kai tested. Then a foldable opens at 673px, a laptop zooms to 125%, someone snaps the browser to half the screen, and next year's phone ships 10px wider. Device widths are a moving target, and there are thousands of them.

VishwaYou built the walls around the furniture, Kai. Build them around what lives inside: the cards.

The better question isn't "what device is this?" but "how much room does a card need before it looks cramped?" If a card is comfortable at about 280px wide, two of them plus a gap need roughly 640px. That's your first breakpoint, and it came from your content, not from a phone catalogue.

The setup: CSS Grid does the heavy lifting

Start mobile-first. The base rule is the smallest layout, so phones need no media query at all:
style.css
/* Base: one column. No media query needed. */
.cards {
display: grid;
grid-template-columns: repeat(1, 1fr);
gap: 12px;
}

Adding breakpoints

Each wider layout is layered on with a min-width query: "from this width upwards, do this instead".
style.css
/* Tablet: 2 columns */
@media (min-width: 640px) {
.cards {
grid-template-columns: repeat(2, 1fr);
gap: 14px;
}
} /* Laptop: 3 columns */
@media (min-width: 900px) {
.cards {
grid-template-columns: repeat(3, 1fr);
gap: 16px;
}
} /* Desktop: 4 columns */
@media (min-width: 1180px) {
.cards {
grid-template-columns: repeat(4, 1fr);
gap: 18px;
}
}
The names "tablet", "laptop" and "desktop" are just labels for humans. The browser only sees widths.

The part that confuses everyone

KaiWait. At 1200px, the 640, 900 and 1180 rules all match. Which one wins?

All three match, because 1200 is wider than all of them. When rules have the same specificity, the last one in the stylesheet wins. That's the cascade. So with min-width, breakpoints must go from smallest to largest; the widest matching rule comes last and takes over. Put the 640px rule at the bottom by mistake and every screen above 640px gets two columns, no matter how wide it is. No error, no warning. Just a layout that stops growing.

Why 1fr makes this painless

  • No percentage maths. repeat(3, 1fr) means three equal shares of the free space. No 33.333%, no rounding gaps.
  • Fluid between breakpoints. Cards stretch and shrink smoothly; the breakpoint only changes how many fit in a row.
  • Gaps are real spacing. gap sits only between cards, so there's no margin on the last item to cancel out.
  • One-line changes. Five columns instead of four? Change one number.

Bonus: a grid with no breakpoints at all

If all you need is "as many cards as fit, each at least 240px wide", Grid can work out the column count by itself:
auto-fit.css
.cards {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
gap: 16px;
}
Use this for simple, even grids. Reach for explicit breakpoints when the layout needs to change in other ways too: gap, padding, font size, or which elements show at all.

A gotcha I hit while building the demo

The live demo resizes a frame, not your whole browser, so it uses container queries instead of media queries. Container queries measure the container's content box: its width minus padding and borders.
demo.css
.frame {
container-type: inline-size;
padding: 16px; /* this padding is subtracted from what the query sees */
}
@container (min-width: 1180px) {
.cards {
grid-template-columns: repeat(4, 1fr);
}
}
My "1200px" frame had padding and a border, so the query actually saw about 1165px. Below 1180, so the four-column layout never switched on. The fix: set the breakpoint for the space the cards really get, or measure an inner element that has no padding.

KaiSo breakpoints come from my content, go smallest to largest, and the box I measure matters. Got it!

Takeaways

  1. Write mobile-first. The base rule is the smallest layout; min-width queries add the rest.
  2. Choose breakpoints from content, not device lists. Widen until the layout looks wrong, then add one.
  3. Use Grid with 1fr and let breakpoints change more than columns: gap, padding and type too.
  4. Remember the cascade. Same specificity means the last matching rule wins, so order breakpoints smallest to largest.

Acharya's Rule

Let the content choose the breakpoint, not the device. Start small, add rules as the room grows, and keep them in order.

Try it yourself: open the interactive breakpoints demo, drag the handle, and watch each rule take over.

Frequently asked questions

What is a responsive breakpoint?+

A breakpoint is the width at which your CSS switches from one layout rule to another, for example from one column below 640px to two columns at 640px and wider.

Should I use min-width or max-width media queries?+

For mobile-first CSS, use min-width. The base styles are for the smallest screens, and each min-width query adds the layout for wider screens. Keep them ordered from smallest to largest.

Which breakpoints should I use?+

Choose them from your content rather than device widths. Widen the layout until it starts to look cramped or stretched, and add a breakpoint there. Common starting points are around 640px, 900px and 1180px.

Can CSS Grid be responsive without media queries?+

Yes. grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)) fits as many columns as there is room for, each at least 240px wide. Use media queries when other things need to change too, such as gap, padding or font size.