liveBook · Manning

Breakpoint

As explained in CSS in Depth, Second Edition

A responsive-design breakpoint is a viewport or container condition at which styles switch between predefined layout or presentation configurations.

A breakpoint is a browser width or height at which page styles change to improve the layout. A mobile-first page starts with styles for narrow screens, then uses media queries to add or override styles as more space becomes available. The HTML stays the same at every size. section 7.1 section 7.2.2

A title that changes at 560 px

Set the title to 1.5rem by default, then add `@media (min-width: 560px) { .title > h1 { font-size: 2.25rem; } }`. Below 560 px, the base size applies; at 560 px and above, the larger size takes over. A media query does not change the selector’s specificity. section 7.2

Choose breakpoints where the layout needs to change, not because every element needs a new rule.

  • At 560 px, give the header and hero more room, replace the menu toggle with visible navigation, and increase spacing. section 7.2.2
  • At 650 px, place the main content in three grid columns. Below that width, leave the items in normal document flow; the columns were too cramped at narrower widths. section 7.2.3
  • Reuse a few breakpoints where useful, but allow an element to change at a different width. Reserve max-width queries for cases where complex mobile-only rules would be tedious to undo. section 7.2.2 section 7.2.3
Listing 7.11 Three-column layout inside a media query
@media (min-width: 650px) {
  .main {
    display: grid;                         #1
    grid-template-columns: 1fr 1fr 1fr;    #1
    gap: 1.5em;
    max-inline-size: 1400px;      #2
    margin-inline: auto;          #2
  }
}

The three-column listing keeps grid styles inside a 650 px min-width query, so the columns appear only when there is enough room. section 7.2.3

Breakpoints can use px or em. In a media query, em is based on the browser’s default font size, so it may respond to a user’s changed default; that behavior is not consistent across all browsers. Use px when that scaling is unnecessary, or em when it is desirable. section 7.2

How CSS in Depth, Second Edition covers it

How deep it goes
Works through mobile-first min-width rules, layout changes, breakpoint choice, and unit trade-offs without specifying a universal set of widths.
Examples
Shows a title resizing at 560 px and a three-column grid appearing at 650 px.
What it assumes
Assumes familiarity with HTML and CSS layout while demonstrating how to add media queries to existing styles.
What you can do after
Build it from scratch by layering media queries over mobile styles and choosing widths where specific layouts become cramped.
How it connects
Connects breakpoints to media queries, mobile-first design, the CSS cascade, grid layout, and normal document flow.

Also explained in

Compare how 2 books explain breakpoint →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of CSS in Depth, Second Edition. The section links point to the parts of the book it draws on.