Learn • Create • Explore

How to Make a Website Responsive

Build a mobile-first reading page and learn how to pick a breakpoint, size images and debug overflow.

A responsive page keeps the same information and controls usable as the available space changes. A small screen might need a single column, while a wide screen can show the main content and a related panel side by side. This guide builds a reading page with a flexible image and a related-notes panel. It also explains how to pick a breakpoint, test a narrow layout, and detect overflow caused by content that was missing from the original mock-up.

A mobile layout shows the article and the notes in sequence, while a wide layout uses two columns

Choose what stays in the reading order

Start with the content in the order you would want a reader to encounter it. Our example puts the main article first and its related notes next. On a phone this order is also the visible layout. At a wide width the notes move into a second column without changing the underlying order. A reader using Tab, a screen reader, or a printed copy can still follow the same structure. Do not start by drawing separate desktop and mobile pages with different copies of the same text. Maintain one source and change the presentation when the layout has room to do so.

A viewport is the area the browser uses to lay out the page. A phone’s physical pixel count and its layout width can differ because multiple physical pixels can represent one CSS pixel. Set the viewport metadata so mobile browsers use the device width for layout rather than simulating a desktop page and shrinking it. This setting enables a sensible starting size, but it does not make a rigid 900-pixel container fit on its own. The rules for widths, wrapping and alignment still matter.

Build a layout that starts with one column

Paste this complete document into the HTML editor and switch the preview between mobile and desktop widths. The page begins with one column. A media query creates two columns only when there is room for both. The image uses a small inline SVG so you can test the layout offline.

HTML example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>A walk by the canal</title>
<style>
  * { box-sizing: border-box; }
  body { margin: 0; color: #10244a; background: #f1f8ff; font: 1rem/1.65 system-ui; }
  .wrap { width: min(100% - 2rem, 65rem); margin-inline: auto; }
  header { padding-block: 1.5rem; background: #d9f4d6; }
  h1 { font-size: clamp(1.75rem, 5vw, 3rem); line-height: 1.15; }
  .content { display: grid; gap: 1rem; padding-block: 1rem; }
  article, aside { min-width: 0; padding: 1rem; background: white; border-radius: .75rem; overflow-wrap: anywhere; }
  img { width: 100%; height: auto; display: block; }
  @media (min-width: 48rem) {
    .content { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); align-items: start; }
  }
</style>
</head>
<body>
  <header><div class="wrap"><h1>A walk by the canal</h1></div></header>
  <main class="wrap content">
    <article>
      <h2>The towpath route</h2>
      <p>Start at the bridge and follow the canal to the old lock.</p>
      <img width="600" height="240" alt="A bridge crosses a blue canal beside a green towpath."
        src="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 600 240'%3E%3Crect width='600' height='240' fill='%23ceecd0'/%3E%3Cpath d='M0 72h600v92H0z' fill='%23087cb8'/%3E%3Cpath d='M280 30h40v190h-40z' fill='%2378432f'/%3E%3C/svg%3E">
      <p>Leave enough room for other path users when you stop to look at the lock.</p>
    </article>
    <aside aria-labelledby="notes"><h2 id="notes">Before you go</h2><p>Check the weather and bring a bottle of water.</p></aside>
  </main>
</body>
</html>
Try it in the HTML editor

The wrapper uses the available width minus two gutters, with a maximum width. That keeps it inside a small viewport and stops it expanding without limit on large displays. The heading grows between a lower and an upper bound, so it does not become tiny to fit a phone or unreasonably large on a wide monitor. The media query works with CSS pixels, which are what matter to the layout.

The wide version reserves a larger share for the article and a smaller share for the notes

Pick a breakpoint from the content

Open the example on a wide screen, then narrow it until the notes panel feels crowded. Watch how many words fit on a line, whether a title breaks into several lines, and where interactive controls would sit. If the panel becomes difficult to read before the existing breakpoint, move the breakpoint so the single-column layout remains in use longer. If both columns remain comfortably usable at a smaller width, try reducing it. This process is more useful than asking which exact phone model a breakpoint targets.

Use minimum-width queries when you are adding room-dependent layout features to the simplest default. Small-screen rules can then be read without piecing together several overrides. When modifying an existing desktop-first site, take care not to mix many contradictory breakpoint rules. Inspect the declarations that apply just below and just above a transition. Test the exact width where conditions change so you catch accidental one-pixel gaps or a declaration that has the same specificity but appears later than intended.

Separate image sizing from image delivery

The example’s image fills its available column and keeps its proportions. The width and height attributes also provide an aspect ratio to reserve the space before the file loads. In a real responsive article, a photo can need different source widths. The display rule only changes how far the browser stretches the image. It does not change which bytes were transferred. Prepare sources that suit the layout and consult the image converter if an ordinary source file can be made smaller without losing useful detail.

Tell the browser the intended slot width when you provide a set of candidate images. At a narrow width the picture can reach almost across the page; on desktop it may sit in the article column. A source size that always says the full screen is too broad can cause larger downloads than necessary. Check the browser’s selected source in the inspector and compare it with the visible width, allowing for screen density.

A responsive slot and the actual image file size are separate decisions

Test overflow and zoom before shipping

Replace a short phrase with an unbroken identifier and add a longer heading to the notes panel. Test at a narrow width, at the breakpoint, and at a comfortable desktop width. If the page has a horizontal scrollbar, identify the element that crosses its boundary. Inspect width, minimum width, padding, and the contents of the affected element. Hiding all horizontal overflow can conceal buttons or information and makes a problem harder to diagnose. Fix the widest culprit or give a dense region an intentional, accessible way to scroll.

Increase browser zoom and check that the visible page still makes sense. Navigation and form controls should remain available as text grows. Test touch targets on a phone and focus indicators with a keyboard. A viewport emulator helps check CSS widths, but it does not reproduce all behaviour of a real touch device or another browser engine. For additional examples see MDN’s responsive design guide.

If you later add a video, reserve its aspect ratio and check the player controls at the smallest intended width. Embedded content can have its own intrinsic size even if the surrounding paragraph wraps normally. Test the embedding element independently before changing unrelated layout rules. A page that handles its most awkward component usually handles the simpler ones as well.

Check the navigation as the page gets narrower

A layout can fit its article while the header still overflows. Add a simple navigation list to the example with three links of different lengths. Allow the list to wrap and measure it at the same widths where you test the main grid. Short labels often make wrapping enough for a small menu. When a larger site needs a collapsed menu, its control should have a readable label, keyboard focus, and an accurate expanded state. The links need to stay usable after resizing from mobile to desktop and back again.

Check both portrait and landscape orientations. A phone turned sideways can give the layout more width but much less height. That is particularly important for fixed headers, panels, and dialogs. The breakpoint might legitimately choose the wide grid although the visible screen is short. Make sure any region that opens over the page can still scroll, and verify that dismissing it returns the visitor to a sensible place.

Run a small regression checklist

Start with the narrowest width you intend to support, then try just below and just above the breakpoint. Record whether the article appears first, whether the image stays proportional, and whether the two columns appear only when expected. Keep a one-line example of the longest plausible heading in the project so it is easy to repeat that test after an edit. Check the layout again when the actual production font loads. A different font can make a navigation label wrap earlier or change how much of a paragraph fits on one line.

Use the CSS editor to compare the final rules with a single-column version without the media query. If the content reads well in both, the breakpoint is enhancing an already usable page. That is a stronger foundation than relying on one carefully sized screenshot.

Related tools

Continue learning