You make a responsive website by writing semantic HTML first, then applying CSS that adapts to screen width instead of assuming one fixed layout. The key condition is a viewport meta tag in the document head; without it, phones render your page at a desktop width and shrink everything. The workflow below takes you from a bare HTML file to a working multi-section page that reflows from a single narrow column on phones to a wider grid on laptops, with a test-and-fix loop you can repeat as you add content.

No special software is needed. A text editor, a browser, and its built-in developer tools are enough. Everything here uses stable, widely supported HTML and CSS features rather than version-specific framework instructions, so it stays accurate as tooling changes.

Prerequisites and the Files You Need

Before writing layout code, set up three things.

A project folder containing one HTML file and one CSS file:

index.html styles.css

Creating the CSS in a separate file keeps the markup readable and lets the browser cache styling on repeat visits. A single combined file also works while learning; you can split it later without changing any HTML beyond the link tag.

A modern browser. Chrome, Firefox, Safari, and Edge all support the features used here, including CSS Grid and flexbox. If you need to support very old browsers, some modern layout properties will silently fall back to stacked block layout, which is still readable, just less polished.

An editing loop you can trust. Open the HTML file directly in the browser, edit, save, and refresh. This works for a static site with no build step. For faster iteration, most editors have a live-preview extension, but a plain save-and-refresh cycle is enough and avoids any setup.

One practical tip before you begin: keep the browser's device emulation panel open while you build. You'll use it constantly, and getting comfortable with it early makes the rest of the process much less frustrating.

Start With Semantic HTML Structure

Write the content and its meaning before you think about layout. Responsive design is much easier when the underlying document makes sense on its own, because a screen reader, a search engine, and a narrow phone screen all benefit from the same clarity.

A workable skeleton for a small business or portfolio page looks like this:

Two details in the head matter more than they appear to.

The viewport meta tag tells mobile browsers to use the device's actual width as the layout width. Remove it and a 390-pixel-wide phone may lay out your page at roughly 980 pixels and zoom out, making text tiny. This single line is the difference between a responsive page and a page that merely looks broken on phones.

The lang attribute on the html element helps screen readers pronounce content correctly and assists translation tools. It costs nothing.

Notice what's absent: no wrapper div soup, no inline styles, no layout classes. Each element describes what it contains. header, nav, main, and footer are landmarks assistive technology users can jump between. The aria-label on the nav distinguishes it if you later add a second navigation region, such as breadcrumbs.

The Viewport Meta Tag and Mobile-First CSS

The viewport tag handles the canvas. Your CSS handles everything inside it. The most reliable habit is to write styles for the narrow case first, then add enhancements as space becomes available. This is called mobile-first authoring, and it prevents the common failure where a desktop design gets awkwardly squished rather than genuinely reconsidered.

In practice, mobile-first means your base styles describe the phone layout:

On a narrow screen, the .cards grid has one implicit column because no columns are declared. Everything stacks. Text stays at a readable size. The nav items wrap onto new lines if needed rather than overflowing.

Then you layer on wider-screen behavior with a media query:

The result: one column below 640 pixels, two columns from 640 to 959, three columns at 960 and above, with the whole grid capped at 1200 pixels and centered on very wide monitors.

Why mobile-first instead of the reverse? Overrides are additive and easier to reason about. You're saying "add a second column when there's room" rather than "remove columns when there isn't." The cascade does less surprising work, and the narrow layout, which is the harder one to get right, gets your primary attention.

Check your work: resize the browser window slowly from very narrow to very wide. The content should reflow at your breakpoints without horizontal scrollbars appearing, and no text should become unreadably narrow or absurdly wide. If a horizontal scrollbar appears, something is wider than the viewport; the next section covers how to find it.

Breakpoints, Fluid Layouts, and When to Use Each

A breakpoint is a width at which your layout changes. Beginners often pick breakpoints by device name (phone, tablet, desktop), but devices are too varied for that to hold. A better principle is to add a breakpoint when the content becomes awkward, for example when a line of text exceeds roughly 75 characters or when cards get too narrow for their content. Content-driven breakpoints survive redesigns and new devices.

Fluid layout is the other half. Some sizing should simply scale with the viewport rather than jump at breakpoints:

clamp(minimum, preferred, maximum) keeps a value inside a range. The heading here is never smaller than 1.75rem, never larger than 3rem, and in between scales with viewport width. Padding behaves the same way. This reduces the number of breakpoints you need, because much of the page is already proportional.

The img rule is one of the highest-value lines in responsive CSS. Without max-width: 100%, a wide image overflows its container and triggers a horizontal scrollbar on phones, which is one of the most common responsive bugs. Setting height: auto preserves the aspect ratio so photos don't stretch.

A reasonable structure for a small site is two or three breakpoints, not seven. Many polished sites use one around 640 pixels and one around 960 to 1024 pixels, with fluid sizing handling everything between. More breakpoints mean more combinations to test; use them when the content genuinely needs them.

A quick way to choose breakpoints: drag the window narrower until the layout looks strained, note that width, and set the breakpoint slightly above it. The strain point is your evidence, not a device chart.

Flexible Images, Media, and Content That Adapts

Images, video, and embedded content are where responsive layouts most often break. Three techniques cover most cases.

Intrinsic sizing. The max-width: 100%; height: auto rule from the previous section applies to video and iframe as well. For iframes, which default to a fixed size, wrap them in a container with aspect-ratio:

aspect-ratio reserves the box's proportions before the iframe loads, so the surrounding layout doesn't jump when the video appears. That jump, called layout shift, is both annoying and measurable by performance tools.

Serving appropriately sized files. A 3000-pixel photo displayed at 400 pixels wastes bandwidth, and on a phone that waste is felt. The srcset and sizes attributes let the browser choose:

You supply multiple files and tell the browser how wide the image will display at various viewport sizes; it picks an appropriate file based on screen density and connection. The width and height attributes give the browser the aspect ratio up front so space is reserved even before the image loads. Modern browsers convert those attributes into an aspect ratio automatically when CSS doesn't override dimensions.

Text measure. Long lines are hard to read. A simple cap helps:

ch is the width of the "0" character in the current font, so 65ch is roughly 65 characters. On wide monitors, this keeps paragraphs in a comfortable reading range instead of stretching edge to edge.

Truncation and overflow. For cards with variable-length titles, decide deliberately whether text should wrap or truncate. Truncation with ellipsis requires overflow: hidden, white-space: nowrap, and text-overflow: ellipsis, and it hides content from sighted users, so use it only where the full text is available elsewhere. Wrapping is usually the safer default.

Navigation is the component most likely to feel wrong on a phone. A horizontal row of five links usually fits; eight don't. You have three practical options.

Wrap the links. The flex-wrap nav from earlier wraps onto a second line when space runs out. This is the simplest solution and often the right one for a small site. No JavaScript, no hidden content, no accessibility traps. If your nav has four to six short items, try this first.

Collapse to a menu button. For larger navigations, a toggle button that shows and hides a vertical list is common. Build it so it works without JavaScript where possible, or so the button state is announced:

The aria-expanded attribute tells assistive technology whether the menu is open. Update it in script whenever the state changes. If you implement a drawer or overlay menu, make sure focus moves into it when opened and returns to the button when closed, and that the Escape key closes it. These details separate a menu that is merely visual from one that is usable.

Use a details element. The native and elements provide toggle behavior with no script:

Style it to appear only below a breakpoint. This is a pragmatic, low-risk option for simple menus; it doesn't handle focus trapping or Escape-to-close the way a custom drawer would, but it also can't break the way a hand-rolled menu can.

Whichever you choose, keep the navigation reachable at every width. Hiding the menu behind a control that only appears at one breakpoint, while removing the visible links at that same breakpoint, is a common bug that leaves tablet users stranded.

Cards and grids need less thought than navigation. A grid with repeat(auto-fit, minmax(260px, 1fr)) fills the available space with as many columns as fit, without media queries:

Each column is at least 260 pixels and grows to share leftover space. The grid reflows from one column on a phone to three or four on a desktop automatically. If the design needs exactly two columns at some widths for editorial reasons, explicit breakpoints are clearer than fighting the automatic behavior.

Test at Real Sizes and Fix What Breaks

Testing is where responsive work becomes reliable. The developer tools device emulation panel lets you set a viewport width and see the result, but there are limits: emulation doesn't reproduce real touch behavior, real network conditions, or real font rendering. Treat it as a fast first pass, not proof.

A practical test sequence:

1: Check the extremes. Set the viewport to about 320 pixels wide (still a useful floor for small phones) and to a full desktop width. Confirm no horizontal scrollbar and that all content is reachable. 2: Sweep the range. Drag the width slowly from narrow to wide. Watch for layout jumps, overlapping elements, clipped text, and images that burst their containers. 3: Test at typical widths. Around 390, 768, 1024, and 1440 pixels cover most real devices. You can also use emulation presets, but treat them as examples, not guarantees. 4: Check touch targets. Interactive elements should be comfortably tappable, commonly at least 44 by 44 CSS pixels. Small links packed tightly are hard to hit. 5: Test with zoom. Zoom the browser to 200 percent. Content should still be readable and operable, which is also an accessibility requirement in many contexts. 6: Use a real phone if you can. Load the page on an actual device over the network. Font sizes, tap behavior, and scrolling can feel different from emulation.

Find the overflowing element. When a horizontal scrollbar appears, the culprit is usually one element wider than its parent. In most browsers, you can select an element in the developer tools and check its computed width, or temporarily add outline: 1px solid red to all elements to see which one extends past the edge. Common causes are a long unbroken word or URL, a fixed-width image, a wide table, or a negative margin. For long strings, overflow-wrap: break-word on the container helps. For tables, either let them scroll inside a wrapper with overflow-x: auto or restructure them into blocks on narrow screens.

Stop condition: If the layout breaks only in one obscure browser while working correctly in current versions of the major browsers, it's often not worth custom fixes; note it and move on. If the page fails accessibility checks on contrast, keyboard navigation, or form labeling, address those before launch rather than after, since retrofitting is considerably harder than building it right.

A simple success check: at every width from 320 pixels to 1920 pixels, you can read all text, reach every link, and no content requires horizontal scrolling. That standard catches most real problems.

Common Mistakes and How to Avoid Them

Most responsive failures come from a short list of recurring mistakes. Knowing them shortens your debugging considerably.

Fixed pixel widths on major containers. A width: 1000px wrapper forces horizontal scroll on any screen narrower than that. Use max-width with a percentage or no width at all, and let the body fill available space.

Content hidden by overflow without a scroll path. overflow: hidden on a container that wraps a wide table or long menu silently clips content. Either allow scrolling on that container or restructure the layout.

Font sizes in fixed pixels with tiny bases. A 12px body font is uncomfortable on a phone viewed at arm's length. Use rem units tied to a sensible root size, and consider larger base text for the mobile layout rather than smaller.

Testing only in the emulator. Emulators approximate, but they don't catch every rendering difference, and they won't reveal that a tap target is too small in practice.

Adding breakpoints everywhere. If a design needs a media query at 360, 480, 600, 768, 900, and 1200 pixels, the underlying layout probably needs a more fluid approach. Fewer, content-driven breakpoints are easier to maintain.

Forgetting hover and focus states on touch. Touch devices have no hover. Anything revealed only on hover should also be available on tap or always visible. Focus styles must be visible for keyboard users, so don't remove outlines without providing an equivalent.

Assuming a hamburger menu is always better. Many sites would be simpler and more usable with a wrapping horizontal nav. A hidden menu adds a click and, done poorly, accessibility problems. Test the simplest option before adding complexity.

Layout shift from late-loading media. Reserve space with aspect ratios and dimensions so images and embeds don't push content around as they load. This is a quality-of-experience issue as much as a performance one.

Where to Go After Your First Responsive Page

A single responsive page is a foundation, not the finished practice. The next useful steps, in rough order of value:

Build a second page using the same stylesheet so you test shared components rather than one-offs. A contact form is a good exercise because it combines responsive layout, touch targets, and accessible labeling.

Add a small form with labeled inputs, sensible input types such as email and tel, and error messages that appear in text rather than color alone. Forms are where many responsive layouts quietly fail on phones.

Learn the container query. Media queries respond to the viewport, but components often need to respond to their own container's width. Container queries let a card adjust its internal layout based on the space it's given, which is useful when the same card appears in a narrow sidebar and a wide main column. Support is broad in current browsers; check your audience's browser mix if you need older support.

Check accessibility systematically. Keyboard-only navigation, visible focus, sufficient color contrast, and meaningful alt text are the high-value checks. Automated tools catch some issues, but manual testing catches more.

Measure performance on a throttled connection. A responsive layout that loads a multi-megabyte hero image still feels slow on a phone. Compressing images and serving appropriately sized files often matters more than any CSS refinement.

As you extend the site, keep the mobile-first discipline: write the narrow layout first, add wider behavior in media queries, test at the extremes before you polish the middle, and treat every fixed width as a question. The techniques here are stable and don't depend on a framework, so they'll continue to apply as the tools around them change. If a future browser feature or framework offers a better way to do something, you'll be able to judge it against a clear baseline of how the fundamentals work.