To make a website responsive, add the viewport meta tag, build the layout with fluid widths and flexbox or grid instead of fixed pixel widths, use media queries to rearrange the layout at a few breakpoints, serve images at the right size with srcset, and size text with clamp() so it scales smoothly. A responsive site is one HTML file and one stylesheet that reshapes itself for a phone, a tablet, and a desktop — no separate mobile site, no duplicate pages. This guide works through each step with real code and worked numbers, so you can apply it to a site you already have or a new one you are building.
Start with the images — the fastest win: responsive images are where most sites waste the most bandwidth. Use our free Image Resizer to create the 400, 800, 1,200 and 1,600-pixel versions your srcset needs, check the proportions with the Aspect Ratio Calculator, shrink each file with the Image Compressor, and convert them to WebP with Image to WebP. Everything runs in your browser — no account, no upload to a server. The srcset section below shows exactly which sizes to generate and why.
What Responsive Design Actually Means — and Why It Matters
Responsive web design, a term coined by Ethan Marcotte in 2010 and defined in his A List Apart article, is a design strategy that responds to users' needs and their devices' capabilities by changing a site's layout to suit the device being used. The web.dev guide to responsive basics puts it plainly: a responsive site might show content in a single-column view on a phone, two columns on a tablet, and three or four columns on a desktop computer. Three ingredients make it work: a fluid grid, flexible images, and media queries. Everything in this guide is one of those three, plus the modern additions — fluid type and container queries — that make the same ideas easier to apply.
The reason it matters is traffic. In September 2026, mobile phones accounted for 58.99% of worldwide page views, desktops and laptops for 39.26%, and tablets for 1.76%, according to StatCounter Global Stats. Mobile leads desktop by 19.73 percentage points worldwide — and the three shares add to 100.01% only because each figure is rounded. The split is not the same everywhere: in the United States the same month, mobile and desktop were almost level at 49.10% and 48.47%. Either way, roughly half of your visitors — and a clear majority worldwide — arrive on a phone. A site that only works at desktop width is a site that fails for half its audience on the first screen.
There is also a search reason. Google indexes and ranks sites primarily by their mobile version, and its Search Central documentation treats a page that requires horizontal scrolling or tiny tap targets on a phone as a poor result. A responsive site is therefore not a cosmetic extra: it is the version of your site that Google judges and that most of your visitors actually see.
Step 1: Add the Viewport Meta Tag
Nothing else in this guide works on a real phone without this one line. Mobile browsers, by default, render a page at a desktop-like width — web.dev puts the usual fallback at about 980 pixels — and then shrink the whole page down to fit the phone screen. Text becomes unreadably small, and your media queries never fire, because as far as the browser is concerned the viewport is 980 pixels wide. The viewport meta tag tells the browser to use the device's real width instead. Add it inside the <head> of every page:
<meta name="viewport" content="width=device-width, initial-scale=1">
The two values each do a job. width=device-width sets the viewport width to the width of the device in device-independent pixels, so the page reflows to match the screen it is actually on. initial-scale=1 sets a 1:1 relationship between CSS pixels and device-independent pixels on first load, so the page also uses the full width when the phone is turned sideways into landscape. Do not add maximum-scale=1 or user-scalable=no: both block pinch-zoom, which people with low vision rely on, and Google's own guidance warns against disabling zoom.
Quick check: open any page on your phone. If you have to pinch-zoom to read the text, or the page loads zoomed out with white space down the sides, the viewport tag is missing or wrong. Fix that first — no amount of media queries will help until the browser knows the real screen width.
Step 2: Build a Fluid Layout with Flexbox or Grid
A fixed-width layout says "this column is 400 pixels wide" and means it on every screen. A fluid layout says "this column takes a third of the available space" and lets the browser do the arithmetic. Percentages, the fr unit in grid, and flexbox's grow and shrink are the tools; fixed pixel widths on containers are the thing to remove.
Here is the worked example this guide returns to: a three-column card layout on desktop that becomes two columns on a tablet and one column on a phone. The base is mobile-first — one column, no media query needed — and the wider layouts are added on top:
/* Base: one column on a phone */
.cards {
display: grid;
grid-template-columns: 1fr;
gap: 24px;
}
/* Two columns from 768px up */
@media (min-width: 768px) {
.cards {
grid-template-columns: 1fr 1fr;
}
}
/* Three columns from 1024px up */
@media (min-width: 1024px) {
.cards {
grid-template-columns: 1fr 1fr 1fr;
}
}
The numbers check out. On a 1,200-pixel-wide desktop container with a 24-pixel gap, the three columns share the container minus the two gaps: (1,200 − 48) ÷ 3 = 384 pixels per column. On a 768-pixel-wide tablet viewport with the same 24-pixel gap, two columns give (768 − 24) ÷ 2 = 372 pixels each. On a 375-pixel-wide phone with 16 pixels of page padding on each side, the single column is 375 − 32 = 343 pixels wide.
Flexbox covers the cases grid does not: navigation bars and button rows that should wrap instead of overflowing — flex-wrap: wrap drops items to a new line, and flex: 1 1 200px lets each item grow but never shrink below 200 pixels. Every image and video on the page also needs one rule, which web.dev recommends verbatim:
img, video {
max-width: 100%;
height: auto;
}
max-width: 100% shrinks an image to fit its container while never stretching it beyond its natural size; height: auto keeps the aspect ratio so the image does not squash. Without this rule, a single 1,200-pixel-wide image is enough to force horizontal scrolling on every phone that visits the page.
Step 3: Choose Breakpoints — and Go Mobile-First
A breakpoint is the viewport width at which the layout changes. The most common mistake is to pick breakpoints from a list of popular phone models. The web.dev guidance says the opposite: do not define breakpoints based on device classes, or any product, brand name, or operating system. Devices change every year; your content does not. The right breakpoint is the width where your layout starts to look wrong — a line of text gets too long to read, a navigation bar runs out of room, a card gets too narrow for its headline. Find it by dragging the browser window narrower until something breaks, and put the breakpoint there.
That said, starting from nothing is easier with a sensible default set, and these four cover the overwhelming majority of sites. They are written mobile-first: the base styles are the phone layout, and each min-width query adds to it as space appears. Writing breakpoints in em units (at the usual 16-pixel root font size, 640px is 40em, 768px is 48em, 1,024px is 64em, and 1,280px is 80em) has one extra benefit: the breakpoints then follow the user's default font size.
| Breakpoint | Same width in em | Typical devices | Layout change |
|---|---|---|---|
| Base (under 640px) | Under 40em | Phones in portrait | Single column, stacked navigation, full-width images |
| 640px | 40em | Larger phones, small tablets in portrait | Two-column cards where they fit, larger tap targets stay |
| 768px | 48em | Tablets in portrait, small laptops | Two-column layout, sidebar appears, navigation unstacks |
| 1,024px | 64em | Laptops, tablets in landscape | Three-column layout, full navigation bar, wider content |
| 1,280px | 80em | Desktop monitors | Content capped at a maximum width, extra whitespace at the edges |
Mobile-first matters for a practical reason as well as a philosophical one: the base stylesheet is the small-screen stylesheet, so a phone downloads no desktop overrides it will never use, and every min-width query only adds what changes. The desktop-first alternative — base styles for a wide screen, then max-width queries to undo them — means writing the layout twice. Four breakpoints is also a ceiling, not a target: most sites need two or three, and each extra one is another layout to test.
How the same layout changes width: viewport width against column width
The chart makes the point the table only implies: responsive design is not about shrinking everything for a phone. The column a reader actually reads stays roughly the same width — 343, 372, and 384 pixels — while the number of columns changes around it. That is the whole trick: keep the reading experience constant and rearrange the furniture.
Step 4: Make Images Responsive with srcset and sizes
A single image file cannot serve every screen. A 1,600-pixel hero looks crisp on a desktop monitor and is pure waste on a phone, where it is displayed 375 pixels wide; a 400-pixel image looks fine on that phone and blurry on the monitor. The srcset and sizes attributes solve this by telling the browser which files exist and how wide the image will be displayed, and letting the browser pick. MDN's responsive-images guidance describes the mechanism: srcset lists the candidate files with their widths in pixels, and sizes tells the browser how wide the image will appear at different viewport widths, using media-query syntax.
Here is the worked example. A hero image sits in a content column that is 800 pixels wide on desktop and full-width on a phone, and four files exist: 400, 800, 1,200 and 1,600 pixels wide.
<img src="hero-800.jpg"
srcset="hero-400.jpg 400w,
hero-800.jpg 800w,
hero-1200.jpg 1200w,
hero-1600.jpg 1600w"
sizes="(max-width: 640px) 100vw, 800px"
alt="A responsive website shown on a phone, a tablet, and a laptop">
The browser's choice follows three steps. First it reads sizes against the viewport to find the display width: on a 375-pixel phone the image is 100vw, so 375 CSS pixels; on desktop it is 800 pixels. Then it multiplies by the device pixel ratio — the number of physical pixels per CSS pixel — because a sharp image needs one image pixel per physical pixel. Then it picks the smallest file that is at least that wide. On a phone with a pixel ratio of 2, the need is 375 × 2 = 750 pixels, so the browser picks the 800-pixel file. On a desktop with a pixel ratio of 2, the need is 800 × 2 = 1,600 pixels, so it picks the 1,600-pixel file. On a standard desktop display with a pixel ratio of 1, the need is 800 × 1 = 800 pixels, and the 800-pixel file is enough. The src attribute stays as the fallback for browsers that do not understand srcset.
Two mistakes quietly break this. First, leaving out sizes: without it the browser assumes the image fills the whole viewport (100vw), so on desktop it fetches the largest file for an image that only occupies part of the screen. Second, writing sizes that does not match the CSS: if the stylesheet shows the image at half the viewport and sizes says 100vw, the browser downloads twice the pixels it needs on every visit. Generate the four sizes with the Image Resizer — 400, 800, 1,200 and 1,600 pixels wide from the same original — and check each one keeps the same proportions with the Aspect Ratio Calculator before you upload them. Then run each file through the Image Compressor and convert the results to WebP with Image to WebP; smaller files at the right width are the whole point of the exercise, and a 1,600-pixel JPEG that was never compressed undoes it.
Step 5: Make Typography Fluid with clamp()
Fixed font sizes have the same problem as fixed layouts: a 64-pixel headline that fills a desktop banner overflows a phone screen, and a 32-pixel headline that suits a phone looks lost on a monitor. The old fix was a stack of media queries, one font size per breakpoint, with visible jumps between them. The clamp() function replaces the stack with one line: clamp(minimum, preferred, maximum) uses the preferred value while it sits between the two limits, and the nearest limit when it does not. MDN defines it as resolving to max(MIN, min(VAL, MAX)), and notes that using it for font sizes lets a size grow with the viewport without going below a minimum or above a maximum.
The preferred value is a straight line between two points you choose: the size you want on a small screen and the size you want on a large one. Here is the worked example — a headline that should be 32 pixels at a 360-pixel viewport and 64 pixels at a 1,440-pixel viewport, with the usual 16-pixel root font size. The slope is (64 − 32) ÷ (1,440 − 360) = 32 ÷ 1,080 = 0.02963, so the viewport part is 2.9630vw. The intercept is 32 − 0.02963 × 360 = 32 − 10.67 = 21.33 pixels, which is 1.3333rem. In rems, 32 pixels is 2rem and 64 pixels is 4rem, giving:
h1 {
font-size: clamp(2rem, 1.3333rem + 2.9630vw, 4rem);
}
Check it at the two ends. At a 360-pixel viewport, the preferred value is 21.33 + 0.02963 × 360 = 21.33 + 10.67 = 32 pixels — exactly the small-screen size. At a 1,440-pixel viewport it is 21.33 + 0.02963 × 1,440 = 21.33 + 42.67 = 64 pixels — exactly the large-screen size. Halfway, at a 768-pixel viewport, it is 21.33 + 0.02963 × 768 = 21.33 + 22.76 = 44.09 pixels, or about 2.76rem — a smooth step between the two, with no breakpoint and no jump.
Two guardrails from MDN keep fluid type accessible. First, write the limits in rem, not pixels, so the sizes follow the reader's default font size and browser zoom. Second, keep the maximum at least twice the minimum in relative units — here 4rem against 2rem — so the text can still scale to 200% when a reader zooms, as WCAG's resize-text criterion requires.
Step 6: Container Queries — Responsive Components, Not Just Pages
Media queries ask about the viewport: how wide is the browser window? Container queries ask about the component's parent: how wide is the box this card actually sits in? That difference matters the moment the same component appears in two places — a product card in a wide main column and the same card in a narrow sidebar. A media query gives both copies the same styles, because the viewport is the same; a container query lets each copy respond to its own space.
The syntax has two parts: declare the parent a container, then query it. container-type: inline-size on the parent tells the browser to track its width. Then @container applies rules when the container crosses a width:
.card-list {
container-type: inline-size;
}
.card {
padding: 16px;
}
@container (min-width: 500px) {
.card {
display: grid;
grid-template-columns: 120px 1fr;
padding: 24px;
}
}
Here the card stays stacked until its container is 500 pixels wide, then switches to a two-column layout with a 120-pixel image column — whatever the viewport is doing. A card in a 600-pixel main column gets the wide treatment; the same card in a 300-pixel sidebar stays stacked.
Browser support for size queries is settled: Chrome 105, Edge 105, Firefox 110 and Safari 16, which MDN's compatibility data records as the first versions with unprefixed support, and the feature has been Baseline widely available since February 2023. Style queries — where a container is queried on a custom property, such as @container style(--tone: urgent) — are newer: Chrome and Edge 111, Safari 18, and Firefox 151, which shipped in May 2026. Scroll-state queries remain Chrome-only and experimental, so treat them as progressive enhancement. For size queries, no fallback is needed for any current browser; for style queries, write the base styles so the component still looks right when the query never matches.
Step 7: Test It — The Checklist Before You Ship
Responsive design is verified by testing, not by reading the CSS and feeling confident. Work through this list on every page before it goes live:
1. Open Chrome DevTools and use the device toolbar. Press F12, then click Toggle device toolbar (or Ctrl + Shift + M on Windows and Linux, Command + Shift + M on a Mac). The Dimensions menu offers phone and tablet presets; leave it on Responsive and drag the viewport edge slowly from 1,400 pixels down to 320, watching for the widths where something breaks. Chrome's own device-mode documentation describes exactly this: the toolbar opens in Responsive mode by default, and you can type exact widths into the boxes or pick a device preset.
2. Check the widths that matter, not every width. Test at 320 pixels (the narrowest common phone), 375 (the most common phone width), each of your breakpoints, and your maximum content width.
3. Look for horizontal scrolling. On each width, scroll sideways: if the page moves, something is wider than the viewport. The usual suspects are a fixed-width element (a 600-pixel table, a form, an embedded map), an image without max-width: 100%, a long unbroken word or URL, or a grid with a fixed minimum track. In DevTools, the Elements panel and a quick search for pixel widths in your CSS will find them.
4. Check tap targets. Google's web.dev guidance on accessible tap targets recommends a minimum touch target of around 48 device-independent pixels, with about 8 pixels of space between targets — the 48-pixel square is roughly 9 millimetres, about the size of a finger pad. A 24-pixel icon can stay 24 pixels visually; add 12 pixels of padding on each side and the tappable area becomes 24 + 12 + 12 = 48 pixels, or 2,304 square pixels. The accessibility floor is lower — WCAG 2.2 requires only 24 by 24 CSS pixels at Level AA — but 48 pixels is the size that passes every guideline at once.
5. Test on a real device. DevTools is an approximation: it resizes a desktop browser and applies mobile dimensions, but the code still runs on your computer. Touch behaviour, real font rendering, and actual performance only show up on a phone. Open the page on one Android phone and one iPhone if you can, tap through the navigation, submit the form, and read a full article.
6. Re-check after every change. A new section, a new image, or a plugin update can reintroduce a fixed width. The five-minute drag test from step 1 is the cheapest regression test a site has.
Common Responsive Design Mistakes
| Mistake | What breaks | Fix |
|---|---|---|
| No viewport meta tag | Phones render the page at about 980px and shrink it; media queries never fire | Add <meta name="viewport" content="width=device-width, initial-scale=1"> |
| Fixed pixel widths on containers | Content overflows on narrow screens; horizontal scrolling | Use percentages, fr units, or max-width with fluid widths |
| Images without max-width | A single wide image forces the whole page wider than the phone | img { max-width: 100%; height: auto; } on every image |
| Breakpoints copied from device lists | Layout breaks on the next new phone size; unused breakpoints pile up | Put breakpoints where your content breaks; two or three is usually enough |
| srcset without sizes | Browser assumes 100vw and downloads the largest file everywhere | Write sizes to match the CSS layout exactly |
| Fixed font sizes only | Headlines overflow on phones or look lost on desktops | Use clamp() with rem limits, as in Step 5 |
| Tap targets under 48px | Readers tap the wrong link; Lighthouse flags the page | Pad small icons out to 48 × 48px with 8px gaps |
| Testing only in DevTools | Touch, real fonts, and real performance go untested | Spot-check on a real Android phone and a real iPhone |
| Hiding content on mobile instead of fixing it | Mobile visitors lose information; Google judges the mobile page | Restack and simplify; hide only decoration, never content |
Frequently Asked Questions
How do I make my existing website responsive without rebuilding it?
Add the viewport meta tag first, then add img { max-width: 100%; height: auto; } and replace fixed pixel widths on your main containers with percentages or a max-width. Those three changes fix the most common breakages. Then add one or two media queries for the layout — usually stacking columns below 768px — and convert images to srcset. A rebuild is rarely needed.
What is the best breakpoint for mobile, tablet, and desktop?
There is no official set, and the web.dev guidance warns against choosing breakpoints from device lists. A practical starting set is 640px, 768px, 1,024px and 1,280px, used mobile-first with min-width queries — but the right breakpoints for your site are the widths where your content starts to look wrong, found by dragging the browser narrower until something breaks.
Should I use media queries or container queries?
Use media queries for page-level layout — the number of columns, the navigation, the overall structure — because those depend on the viewport. Use container queries for components that appear in different widths on the same page, such as a card used in both a main column and a sidebar. Size container queries are supported in Chrome 105, Edge 105, Firefox 110 and Safari 16, so they are safe to use for current browsers.
How do I make images responsive without slowing the page down?
Generate several sizes of each image (400, 800, 1,200 and 1,600 pixels wide covers most layouts), serve them with srcset and a sizes attribute that matches your CSS, compress each file, and convert to WebP. The browser then downloads only the size it needs — on a phone with a 2x display showing a 375-pixel-wide image, that is the 800-pixel file, not the 1,600-pixel one. Our free Image Resizer, Image Compressor and Image to WebP tools produce the files.
Why does my site look fine on desktop but broken on mobile?
The most common cause is a missing viewport meta tag: without it, phones render the page at about 980 pixels wide and shrink it, so your media queries never fire. After that, check for fixed-width elements, images without max-width: 100%, and tap targets smaller than 48 pixels. Open the page in Chrome DevTools, turn on the device toolbar, and drag the viewport down to 375 pixels — the breakage will usually be visible immediately.
Do I still need a separate mobile website in 2026?
No. A separate mobile site means two sites to maintain, two sets of URLs, and a redirect that can send visitors to the wrong version. One responsive site serves every screen from the same HTML, which is also the version Google indexes under mobile-first indexing. The only common exception is a genuinely different product — such as an app-like experience — rather than the same content in a narrower column.
Sources: MDN Web Docs, "clamp()" and "CSS Container Queries" and "Responsive images" and "Using media queries"; web.dev, "Responsive web design basics" and "Accessible tap targets"; StatCounter Global Stats, desktop vs mobile vs tablet market share worldwide, September 2026 (mobile 58.99%, desktop 39.26%, tablet 1.76%); Chrome for Developers, "Simulate mobile devices with device mode"; W3C, WCAG 2.2 Success Criterion 2.5.8 (Target Size, Minimum); Ethan Marcotte, "Responsive Web Design", A List Apart (2010). Asad Webs tool pages verified live November 27, 2026. Accessed November 27, 2026.
Want help putting this into practice? If you are building a website, making an existing site mobile-friendly, or planning a content and SEO programme around it, talk to Asad Webs — we build web apps, tools, and SEO content.
Related reading: our guide to how to resize an image online; how to calculate aspect ratio (keep your responsive images in proportion); what Core Web Vitals are; how to speed up a WordPress website; and how to add a favicon to your website.




Be the first to share a useful question or thought.