Sub topic 3
The default breakpoints
This chapter covers the five default breakpoints in Tailwind CSS, the media queries behind them, and how to choose between them. It assumes you know basic HTML and CSS, including flexbox and grid, and that you have used utilities such as flex, p-4 and text-lg. It also assumes you know a CSS media query is a rule that applies only when a condition, such as the viewport width, is true. The mobile-first model from the previous chapter applies throughout. An unprefixed utility applies at every width, and a prefixed one applies from its breakpoint upward.
What a breakpoint is in Tailwind
A breakpoint is a viewport width at which your layout is allowed to change. Tailwind gives each default breakpoint a name. Writing that name and a colon in front of a utility, as in md:flex, wraps the utility in a media query for that width.
Tailwind ships with five breakpoints:
| Prefix | Minimum width (v4) | Minimum width (v3) | Generated media query (v4) |
|---|---|---|---|
| `sm` | 40rem (640px) | 640px | `@media (width >= 40rem)` |
| `md` | 48rem (768px) | 768px | `@media (width >= 48rem)` |
| `lg` | 64rem (1024px) | 1024px | `@media (width >= 64rem)` |
| `xl` | 80rem (1280px) | 1280px | `@media (width >= 80rem)` |
| `2xl` | 96rem (1536px) | 1536px | `@media (width >= 96rem)` |
In Tailwind v3 the generated query is written as @media (min-width: 768px). Tailwind v4 uses the newer range syntax, width >= 48rem. The two forms mean the same thing, and the pixel values are identical (1rem is 16px at the default size). Only the unit and the syntax differ.
There is no xs breakpoint and no prefix for "below sm". The range from 0 to 639px is the base layer, written with no prefix.
Every breakpoint is a minimum
All five prefixes use a minimum width. md: does not mean "tablets". It means "768px and wider", and that includes laptops and desktop monitors. The width range each prefix covers therefore overlaps with the ones above it.
The diagram shows why the model is cumulative. At 1100px the sm:, md: and lg: rules all match. When two of them set the same property, the larger breakpoint wins, because Tailwind emits the variants in ascending order of width, so later (larger) rules override earlier ones with equal specificity.
Two details follow from this:
- The comparison is inclusive. At exactly 768px,
md:applies. - The order of classes in your HTML does not matter.
md:p-8 sm:p-4 p-2andp-2 sm:p-4 md:p-8produce the same result, because the order is set by the generated stylesheet and not by theclassattribute.
A worked example across all five widths
The following element changes its padding and text size at every default breakpoint. Each class sets one property per width, so you can read the cascade directly.
<div class="p-2 text-sm sm:p-4 sm:text-base md:p-6 md:text-lg lg:p-8 lg:text-xl xl:p-10 xl:text-2xl 2xl:p-12 2xl:text-3xl">
Resize the window to watch padding and text size step up.
</div>This is the result at several widths:
| Viewport width | Active rules | Padding | Text size |
|---|---|---|---|
| 400px | base | `p-2` | `text-sm` |
| 640px | base, `sm` | `p-4` | `text-base` |
| 800px | base, `sm`, `md` | `p-6` | `text-lg` |
| 1100px | base to `lg` | `p-8` | `text-xl` |
| 1400px | base to `xl` | `p-10` | `text-2xl` |
| 1600px | base to `2xl` | `p-12` | `text-3xl` |
You rarely need a class at every breakpoint. Most components change at one or two of them. Setting a value at every step is the exception, and it is a sign that something like clamp() or a fluid size would serve better.
Rem units and the browser font size
Tailwind v4 defines its default breakpoints in rem, and v3 defines them in px. The difference matters in one situation. In a media query, rem is relative to the browser's default font size, which is 16px unless the user changed it. It is not relative to a font-size you set on html in your own CSS.
This has two effects:
- In v4, if a user raises their browser's default font size to 20px,
mdtriggers at 960px instead of 768px. The layout then switches to its wide form later, which gives the larger text more room. This is usually the behavior you want for accessibility. - In v3, the pixel breakpoints ignore the user's font size setting. Larger text can overflow a layout that was sized for 16px.
Setting html { font-size: 62.5% } in your stylesheet does not change breakpoint widths in either version. It changes what 1rem means for elements on the page, not inside media queries.
Choosing which breakpoint to use
The default values reflect common device classes, but you should not pick a breakpoint by matching a device. Phones, tablets and laptops come in a wide range of widths, and window sizes on desktop are arbitrary. Pick the breakpoint where your content starts to look wrong.
A practical method:
- Build the layout for the narrowest width first, with no prefixes.
- Widen the window slowly and watch for the first point where the content looks stretched, cramped or sparse.
- Add the smallest default breakpoint at or below that width and put the fix there.
- Repeat until the widest layout you support looks right.
In practice this tends to produce a few recurring roles for the defaults:
sm(640px): one-column content can become two columns, and larger phones in landscape reach this width.md(768px): navigation often switches from stacked to inline, and sidebars become possible.lg(1024px): full multi-column layouts, with a sidebar and a main column side by side.xl(1280px) and2xl(1536px): usually small refinements, such as larger gaps, wider max widths or an extra grid column.
These are tendencies, not rules. A narrow content-focused page might never need anything beyond md.
Using the defaults in layouts
The grid below starts with one column at every width. It moves to two columns at 640px and three at 1024px.
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3">
<div class="rounded border p-4">One</div>
<div class="rounded border p-4">Two</div>
<div class="rounded border p-4">Three</div>
</div>Between 640px and 1023px, sm:grid-cols-2 applies, because lg:grid-cols-3 has not matched yet. From 1024px, both match, and lg:grid-cols-3 wins because it is emitted later.
Here is a navigation that stacks by default and becomes a row at md:
<nav class="flex flex-col gap-2 md:flex-row md:items-center md:gap-6">
<a href="/">Home</a>
<a href="/docs">Docs</a>
<a href="/pricing">Pricing</a>
</nav>Only the properties that change are prefixed. flex stays unprefixed because the element is a flex container at all widths. Only the direction, alignment and gap differ.
Type scales follow the same pattern:
<h1 class="text-2xl font-bold md:text-4xl lg:text-5xl">Responsive heading</h1>The base size serves the smallest screens. The heading grows at md and again at lg, and font-bold applies everywhere.
Mistakes that come from misreading the defaults
Treating `sm:` as "small screens"
The most common error is writing sm: to target phones. Because sm means 640px and up, a class such as sm:hidden hides the element on everything from 640px wide, which includes desktops. To hide an element on phones only, write hidden sm:block. Hiding means a different display at the base width, and showing again at the breakpoint.
<!-- Wrong: visible on phones, hidden on tablets and desktops -->
<aside class="sm:hidden">Phone-only banner</aside>
<!-- Right for "phones only" if you want it hidden from sm upward: same result -->
<!-- Right for "desktop only": hidden by default, shown from lg -->
<aside class="hidden lg:block">Desktop sidebar</aside>The first line is not wrong in effect. It shows a banner on phones only. The common error is expecting it to show on tablets. Read each prefixed class as "from this width upward" and the confusion goes away.
Missing the viewport meta tag
Without the viewport tag, mobile browsers report a layout width of about 980px, and the base layer never applies on phones. Add this to the document head:
<meta name="viewport" content="width=device-width, initial-scale=1">Expecting the breakpoint to match the container
The defaults measure the viewport, not the parent element. A card in a 300px sidebar on a 1400px screen still sees xl as active. When a component must respond to the space it is given, use container queries, which a later chapter covers.
Changing the same property in the wrong direction
If you write lg:p-4 p-8, the padding shrinks as the screen widens. That is valid, but it is often a sign that the base value is wrong for a mobile-first design. Check that each larger breakpoint adds to the layout instead of undoing a base style.
Where the defaults come from
The values live in the theme, and every breakpoint is a theme entry. In v4 the entries are CSS variables, --breakpoint-sm: 40rem and so on. In v3 they are the screens key of the config. Because they are ordinary theme data, you can add to them or replace them. A later chapter shows how to add a 3xl breakpoint. For now, remember that nothing about the five defaults is fixed in the framework, and your choice of breakpoints is a design decision.
Quick reference
- Breakpoints are minimum widths: 640, 768, 1024, 1280 and 1536px.
- Unprefixed classes cover all widths, and prefixed classes cover their breakpoint and above.
- The comparison is inclusive at the threshold.
- Class order in HTML does not affect which rule wins.
- v4 uses rem in media queries, and rem there follows the browser default font size.
- Choose breakpoints from where your content breaks, not from device names.
Exercise
A banner has the classes block sm:hidden lg:block. For each of these viewport widths, say whether the banner is visible: 500px, 700px, 1024px.
Show answer
At 500px it is visible, because only block applies. At 700px it is hidden, because sm:hidden matches (640px or wider) and lg:block has not matched yet. At 1024px it is visible again, because lg:block matches and is emitted after sm:hidden, so it overrides it.
Exercise
A teammate wants a sidebar to appear only on phones and writes sm:block hidden. What does it actually do, and what should they write if the sidebar must show only below 640px?
Show answer
It hides the sidebar below 640px and shows it from 640px upward, which is the opposite of the intent. For a phone-only sidebar, show it by default and hide it from sm upward: block sm:hidden. The max-sm: variant, covered in a later chapter, also expresses this directly.
Exercise
In Tailwind v4, a user sets their browser default font size to 20px. At what viewport width does md: start to apply, and why?
Show answer
At 960px. The v4 breakpoint is 48rem, and in a media query 1rem equals the browser default font size, so 48 x 20 = 960px.