min-width media query adds changes as the screen gets wider. The big question is: which widths should you pick? This guide gives you a practical starting set and a better way to choose your own.A good starting set of breakpoints
There is no official standard, but these four values cover most phones, tablets, laptops and large monitors:
| Breakpoint | Typical devices | Usual change |
|---|---|---|
| Base (no query) | Phones | Single column, stacked layout |
| 480px | Large phones, landscape | Slightly larger spacing |
| 768px | Tablets | Two columns, show full navigation |
| 1024px | Small laptops | Three columns, sidebar appears |
| 1280px | Desktops | Wider container, more whitespace |
/* Base: mobile styles, no media query */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 768px) {
.grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1024px) {
.grid { grid-template-columns: repeat(3, 1fr); }
}
Rule 1: Let the content choose the breakpoint
Device widths change every year, so a breakpoint tied to one phone model gets outdated quickly. A better method is to start with the narrowest layout and slowly widen the browser. The moment the layout looks stretched or awkward, add a breakpoint at that width. Your design decides the numbers, not a device list.
Tip: if a line of text gets longer than about 75 characters, that is often a good sign it is time for a new layout.
Rule 2: Use as few breakpoints as you can
Every breakpoint is one more state to test and maintain. Many sites work well with just two or three. If a component only needs a change at one width, give that component its own breakpoint instead of forcing it to follow a global list.
Rule 3: Use CSS variables for the values you repeat
Media queries cannot read CSS custom properties, so you can not write @media (min-width: var(--tablet)). Instead, keep your breakpoints in one place by writing them as a short comment block at the top of your stylesheet, or use a preprocessor variable if you use Sass:
/* Breakpoints
sm: 480px | md: 768px | lg: 1024px | xl: 1280px */
Rule 4: Prefer min-width, and avoid mixing
Stick with min-width across the whole file. Mixing max-width and min-width makes the cascade harder to follow, and it can leave a gap or an overlap at the exact breakpoint. If you are moving an older desktop-first stylesheet, the free ConvertSwift max-width to min-width converter flips the queries and sorts them from small to large for you.
Rule 5: Keep media queries in order
Because later rules override earlier ones, mobile-first queries should go from smallest to largest. If a 1024px rule comes before a 768px rule, the 768px rule can win on large screens by accident.
/* Correct order: small to large */
@media (min-width: 768px) { ... }
@media (min-width: 1024px) { ... }
@media (min-width: 1280px) { ... }
px, em or rem for breakpoints?
Pixels are simple and are what most developers use. However, em based breakpoints respond to the user's browser font size, so the layout adapts when someone has increased their default text size. In media queries, em is based on the browser's default font size (usually 16px), so 48em equals 768px by default. Either choice is fine, just stay consistent in one project.
Common mistakes
- Writing desktop styles first, then overriding them for mobile.
- Adding too many breakpoints "just in case".
- Putting queries in the wrong order.
- Testing only at exact breakpoint widths and not in between.
- Forgetting the viewport tag:
<meta name="viewport" content="width=device-width, initial-scale=1">
Quick recap
- Write base styles for mobile, then add
min-widthqueries. - 480, 768, 1024 and 1280px are a solid starting set.
- Let your content decide the real breakpoints.
- Keep queries ordered from small to large.
FAQ
How many breakpoints should I use?
Two to four is enough for most websites. Add more only when the layout really breaks.
Is 768px still a good tablet breakpoint?
Yes, it is a widely used value. Treat it as a starting point and adjust to your design.
Can I use min-width and max-width together?
You can, for a query that applies only inside a range, but for most projects it is simpler to use only min-width.

No comments:
Post a Comment