{"canonical_url":"https://engineer.company/glossary/responsive-design/","content_markdown":"# Responsive design\n\n## What it is\n\nResponsive design is the practice of building one page whose layout adapts to\nwhatever screen it is read on, from a narrow phone held upright to a wide\nmonitor, instead of building a separate site for each kind of device. The longer\nspelling, responsive web design, is the title of the article that named it:\nEthan Marcotte's piece in A List Apart, published on 25 May 2010. He drew the\nidea from what he described as an emergent discipline called responsive\narchitecture, in which walls and installations move and change shape as people\ncome near them.\n\nMarcotte called fluid grids, flexible images and media queries “the three\ntechnical ingredients for responsive web design”. A fluid grid sizes its columns\nin proportions of the space available rather than in fixed pixels, so the layout\nstretches and shrinks with the window. A flexible image is never allowed to grow\nwider than the column that holds it. A media query lets a stylesheet change its\nmind at the points where proportions alone stop working: when three columns\nbecome too narrow to read, for example, the page switches to one.\n\nThe Media Queries Level 4 specification, a W3C Candidate Recommendation Draft\ndated 19 February 2026, defines a media query as a logical expression with one\nof two values, true or false: a test of some aspect of the browser or device\nthat is showing the document. The test responsive layouts lean on is `width`,\nwhich for a screen is the width of the viewport, scroll bar included. Lengths in\na query are the same CSS lengths as anywhere else, so a pixel there is a CSS\npixel, not a physical one, and an `em` is measured from the browser's initial\nfont size, which the reader can change, never from any size the page itself\nsets.\n\nNone of this works on a phone unless the page asks for it. Without a viewport\nmeta element, mobile browsers lay a page out as if the screen were a desktop\nwindow, typically 980 to 1024 CSS pixels wide, and then shrink the result, so\nevery media query sees a desktop. The CSS Viewport draft calls that a mitigation\nfor pages designed only for large screens, unnecessary for pages that work well\non small ones, and the line `width=device-width, initial-scale=1` in the example\nbelow is how a page says it is one of them.\n\n## Why it matters\n\nMarcotte's argument was about maintenance as much as appearance. Rather than\ntailoring disconnected designs to an ever growing number of devices, he proposed\ntreating them as facets of the same experience. One page, one address and one\nstylesheet mean that a correction reaches every reader at once, and a new size\nof screen is served by the same site, because the layout was never written for a\nparticular size in the first place.\n\nZoom is the reason many teams underestimate. Zooming in makes the CSS pixel\nbigger, so the viewport, counted in CSS pixels, gets narrower. The Web Content\nAccessibility Guidelines 2.2, a W3C Recommendation dated 12 December 2024,\nrequire at level AA in Success Criterion 1.4.10 Reflow that content can be used\nwithout scrolling in two dimensions when the available width is 320 CSS pixels,\nand they spell out that this is what a window 1280 CSS pixels wide becomes at\n400% zoom. At that starting width, every media query on the page sees a reader\nwho zooms a laptop browser to 400% as using a 320-pixel viewport. The W3C's\nexplanation of the criterion observes that sites commonly use responsive design\nto fit smaller viewports, and that content which fits a small viewport helps\npeople who zoom in on larger devices, not only people on phones.\n\nBytes are the third reason. The HTML Standard lists three separate reasons to\noffer several files for one image: choosing by viewport, art direction, and\nchoosing by image format. A photograph shown across a phone needs far fewer\npixels than the same photograph across a large monitor, and with `srcset` and\n`sizes` the browser can fetch the smaller file without any script.\n\nWidth is not the only thing a page can respond to. Media Queries Level 4 also\ndescribes the primary pointing device: `(pointer: coarse)` matches a pointing\ndevice of limited accuracy, such as a touch screen, and `(hover: none)` matches\na primary pointing device that cannot hover, or no pointing device at all.\nMarcotte's article already suggested using media queries to give links bigger\ntargets on small screens.\n\n## What it looks like in practice\n\nA list of cards that shows one column on a phone, two on a tablet held sideways\nand three on a wide screen starts with the viewport line and an image the\nbrowser can choose for itself:\n\n```html\n\u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\" /\u003e\n\n\u003cimg\n  src=\"pool-400.jpg\"\n  srcset=\"pool-400.jpg 400w, pool-800.jpg 800w, pool-1600.jpg 1600w\"\n  sizes=\"(max-width: 40em) 100vw, (max-width: 64em) 50vw, 33vw\"\n  width=\"1600\"\n  height=\"900\"\n  alt=\"A tide pool at low water\"\n/\u003e\n```\n\nThe stylesheet carries the layout:\n\n```css\n.cards {\n  display: grid;\n  grid-template-columns: 1fr;\n  gap: 1rem;\n}\n\n@media (width \u003e= 40em) {\n  .cards {\n    grid-template-columns: repeat(2, 1fr);\n  }\n}\n\n@media (width \u003e= 64em) {\n  .cards {\n    grid-template-columns: repeat(3, 1fr);\n  }\n}\n\n.cards img {\n  max-width: 100%;\n  height: auto;\n}\n```\n\nThe grid is the fluid part: `1fr` columns share whatever width there is, so\nnothing has a fixed size. The two media queries are the switches, and because\nthey are written in `em`, they follow the reader's default text size. Someone\nwho has set a larger default font gets the single column at window widths where\nothers already see two, which is exactly what the longer lines would need. The\nlast rule keeps every image inside its column.\n\nThe `sizes` attribute tells the browser, before it has laid anything out, how\nwide the image will be shown: the first condition that is true wins, and the\nlast value applies when none is. At a viewport 39em wide, the first condition is\ntrue, so the image counts as 39em wide; at 41em, the second one is, and the\nimage counts as half the viewport, 20.5em. The slightly wider window needs the\nsmaller file, because the layout has changed, and the HTML Standard works\nthrough the same effect in its own example. From those numbers and the `w`\ndescriptors in `srcset`, the browser works out how dense each file would be on\nthis screen and may pick any of them, taking the screen's pixel density, the\nzoom level and possibly the network into account. The `width` and `height`\nattributes let it allocate space for the image before the file has been\ndownloaded.\n\n[A portfolio entry on making the site's browser checks faster](/portfolio/a-safety-net-that-no-longer-costs-half-an-hour/)\nshows the same idea turned into a test. In that work, which was carried out in\nAugust 2026, the checks that drive a headless browser were given one shared\ntable of twenty-two window shapes, derived from every media query the stylesheet\nactually contains, and the layout check, which looks at the page at every window\nshape the design draws, went from 95 seconds to 405 as a result. The shapes come\nfrom the stylesheet, not from a list of devices, so the breakpoints the design\nactually has are the ones the pages are checked at.\n\n## Where it goes wrong\n\n**Breakpoints that ask about the device.** Marcotte's 2010 examples queried\n`max-device-width`, the width of the whole screen. Media Queries Level 4 now\ndeprecates `device-width`, `device-height` and `device-aspect-ratio`, says\nauthors must not use them, and notes that they are often used as a proxy for\ndetecting mobile devices, while they say nothing about how much space the page\nactually has. Query `width` instead, and put each breakpoint where the content\nstops working, not where a popular phone happens to end.\n\n**A gap between two breakpoints.** A stylesheet with `(max-width: 320px)` for\none layout and `(min-width: 321px)` for the next looks complete, but the\nspecification points out that a viewport between 320 and 321 pixels wide matches\nneither, and fractional widths are real: they come from screens with non-integer\npixel densities and from zoom. At those widths, neither block of styles applies.\nUse the range syntax, `(width \u003c= 320px)` and `(width \u003e 320px)`, so that every\nwidth falls into exactly one of them.\n\n**Zoom switched off.** A viewport line with `user-scalable=no`, or with a\n`maximum-scale` below 2, fails the W3C's test rule for Success Criterion 1.4.4\nResize Text, which asks that text can be enlarged to 200 percent. The rule notes\nthat desktop browsers pay no attention to the element, and that on mobile most\ncurrent browsers disregard it out of the box or give the reader an accessibility\nsetting to zoom regardless, so the people still affected are those on older\nmobile browsers. Leave both properties out and make the layout survive zoom\ninstead. A smaller font in a narrow breakpoint needs the same care: the W3C's\nexplanation of Reflow allows it, but only if the reader can still get text to\ntwice its normal size in some way.\n\n**Images that ignore the layout.** With `w` descriptors in `srcset` and no\n`sizes`, the HTML Standard makes the browser assume the image fills the whole\nviewport, so a picture shown in a third of the screen may download a file about\nthree times wider than it needs. Percentages are not allowed in `sizes`; use\n`vw`. And when `srcset` uses `w` descriptors, browsers that understand `srcset`\nignore `src`, so changing only `src` changes nothing for most readers. Write\n`sizes` to match the CSS, and change both together when the layout changes.\nChoosing images in a script is no fix: the standard warns that it can download\nthe image twice, or not at all for readers with scripting turned off.\n\n**One wide element pushes the page sideways.** A data table, a long line of code\nor an embed with a fixed width can be wider than 320 CSS pixels and make the\nwhole page scroll horizontally, so that every paragraph has to be read by\nscrolling back and forth. The W3C's explanation of Reflow excepts content that\nneeds two dimensions, such as data tables, maps and video, but not the\nparagraphs around them. Put the table in its own container that scrolls by\nitself with `overflow-x: auto`, and give images and video `max-width: 100%`, so\nthat only the part that needs it scrolls.\n\n**Taking a narrow screen for a touch screen.** A laptop zoomed to 400% is narrow\nand has a mouse; a large tablet is wide and has no hover at all. Layout belongs\nto `width`, and target sizes and hover effects belong to `pointer` and `hover`.\nMedia Queries Level 4 advises authors to consider `any-pointer` and `any-hover`\nas well, since a device can have more than one way to point.\n\n## Further reading\n\n- [Responsive Web Design](https://alistapart.com/article/responsive-web-design/)\n  — Ethan Marcotte's article of 25 May 2010 that named the approach and its\n  three ingredients.\n- [Media Queries Level 4](https://www.w3.org/TR/mediaqueries-4/)\n  — the `width` feature, the range syntax, relative units, pointer and hover,\n  and why `device-width` is deprecated.\n- [HTML Standard: Images](https://html.spec.whatwg.org/multipage/images.html)\n  — `srcset`, `sizes`, the three reasons for several files, and the worked 29em\n  and 32em example.\n- [Understanding Success Criterion 1.4.10: Reflow](https://www.w3.org/WAI/WCAG22/Understanding/reflow.html)\n  — why 320 CSS pixels, how zoom relates to it, and which content is excepted.\n- [Meta viewport allows for zoom](https://www.w3.org/WAI/standards-guidelines/act/rules/b4f0c3/)\n  — the W3C test rule for `user-scalable` and `maximum-scale`, with its note on\n  browser support.\n- [CSS Viewport Module Level 1](https://www.w3.org/TR/css-viewport-1/)\n  — the viewport meta element, its properties and why mobile browsers assume a\n  desktop width.\n\n\u003chttps://engineer.company/glossary/responsive-design/\u003e\n","date_modified":"2026-11-09T21:50:25Z","description":"How one page fits every screen: fluid layouts, media queries, images chosen with srcset and sizes, what zoom has to do with it, and where it breaks.","formats":{"gemtext":"https://engineer.company/glossary/responsive-design/index.gmi","gopher":"https://engineer.company/glossary/responsive-design/gophermap","html":"https://engineer.company/glossary/responsive-design/","json":"https://engineer.company/glossary/responsive-design/index.json","markdown":"https://engineer.company/glossary/responsive-design/index.md","pdf":"https://engineer.company/glossary/responsive-design/index.pdf"},"kind":"page","language":"en","title":"What is responsive design?","url":"https://engineer.company/glossary/responsive-design/","version":1}