HTML & CSSEasy
What are breakpoints?
Breakpoints are the widths at which a responsive layout changes, for example from one column to two, implemented with media queries (or container queries). Good breakpoints are chosen where the content starts to look broken or cramped, not to match particular devices.
Typical ranges (Tailwind's defaults as a reference)
| Name | Min width | Typical change |
|---|---|---|
sm | 640px | Larger phones in landscape |
md | 768px | Tablets: two columns, show sidebar |
lg | 1024px | Laptops: full navigation |
xl | 1280px | Desktops: wider grids |
2xl | 1536px | Large screens: cap content width |
Use them as a starting point, not as rules.
How to choose them
- Start with the narrowest layout (mobile first).
- Widen the browser until something looks wrong (lines too long, too much empty space).
- Add a
min-widthbreakpoint there.
Best practices
- Keep a small, shared set as design tokens so every component agrees.
- Use
emorremunits (48em) so breakpoints respect browser zoom and font settings. - Prefer component-level container queries for reusable widgets that live in sidebars and main areas alike.
- Reduce breakpoints with intrinsic layouts:
clamp()for type and spacing,repeat(auto-fill, minmax())for grids,flex-wrap. - Remember people zoom to 200% or more, which effectively triggers smaller breakpoints on desktops.
Interview tip
Saying "breakpoints come from the content, not the device list" is the answer interviewers want to hear.
Code example
html
1<style>2 :root { --bp-md: 48em; } /* custom properties cannot be used inside @media, so document them here */3 body { font-family: system-ui; margin: 0; }4 .wrap { max-width: 72rem; margin-inline: auto; padding: 12px; }5 .grid { display: grid; gap: 10px; grid-template-columns: 1fr; }6 .grid div { border: 2px solid #0b1020; padding: 12px; background: #fef9c3; border-radius: 8px; }7 h1 { font-size: clamp(1.4rem, 4vw, 2.4rem); } /* fluid: no breakpoint needed */8 @media (min-width: 40em) { .grid { grid-template-columns: repeat(2, 1fr); } } /* sm: 640px */9 @media (min-width: 64em) { .grid { grid-template-columns: repeat(4, 1fr); } } /* lg: 1024px */10</style>11<div class="wrap">12 <h1>Breakpoints from content</h1>13 <div class="grid"><div>Card</div><div>Card</div><div>Card</div><div>Card</div></div>14 <p id="w"></p>15</div>16<script>17 const show = () => (document.getElementById("w").textContent = `Viewport: ${innerWidth}px`);18 addEventListener("resize", show);19 show();20</script>
Practice this question
Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the HTML & CSS set.