An HTML page fits a mobile screen when the browser's layout viewport matches the device width, text and images scale without horizontal scrolling, and interactive targets stay reachable with one thumb. The single most important step is adding a viewport meta tag, usually , to the head of every page. That one line stops the common failure where a phone renders a 980-pixel-wide desktop canvas and shrinks everything, making text tiny and forcing sideways pinching. Everything else—fluid widths, flexible media, sensible breakpoints, and touch-friendly controls—builds on that foundation.

The steps below are ordered so each one depends on the previous. You can start from an existing desktop-focused page or a blank file; no build tools or frameworks are required. You'll need a text editor, a browser with device-emulation tools (Chrome, Firefox, Safari, and Edge all include them), and ideally one real phone for a final check, because emulation can't reproduce everything.

Start With the Viewport Meta Tag and a Correct Document Skeleton

The viewport meta tag is a hint to mobile browsers telling them how to size the layout viewport relative to the physical screen. Without it, mobile browsers apply a default virtual width—commonly around 980 CSS pixels—and scale the result down so the whole page is visible. That's why an unmodified desktop page on a phone shows microscopic text and a whole-page zoom-out.

Why width=device-width matters

width=device-width sets the layout viewport's width to the device's width in CSS pixels, so your CSS sees roughly the same width the phone physically offers. initial-scale=1 sets the initial zoom to 1:1. Together they mean a paragraph styled at 16px renders at roughly 16 CSS pixels rather than being squeezed.

A minimal, mobile-ready skeleton looks like this:

Two supporting details matter. The declaration triggers standards mode; without it, some browsers fall back to quirks mode with different box-sizing and layout behavior. The charset declaration ensures text renders correctly. Neither is strictly about mobile, but both prevent layout surprises that surface when you start testing on phones.

What to check after this step

Open the page in a desktop browser, turn on device emulation (in Chrome, open DevTools and toggle the device toolbar; in Firefox, use Responsive Design Mode), pick a common phone size such as 375×667 or 390×844 CSS pixels, and confirm the content fills the width without zooming. If the page still appears to render at a wide width and shrink, the meta tag is missing, misspelled, or placed after other head content in a way that a template is overriding. View the page source and confirm the tag appears exactly once in the head.

One common mistake: duplicating the viewport tag across a layout template and a page-specific template. Multiple tags can conflict, and later ones may win. Keep a single authoritative tag in your base template.

Replace Fixed Widths With Fluid Ones

With the viewport set, the next cause of horizontal scrolling is fixed pixel widths. A container declared at width: 960px cannot shrink to a 375-pixel screen, so the browser either lets it overflow (creating sideways scroll) or squeezes neighboring content.

Converting fixed widths

The reliable rule: replace fixed widths on layout containers with max-width plus percentage or no width. A wrapper that was width: 960px becomes max-width: 960px; width: 100%;. Then add horizontal padding so text doesn't touch the edges:

box-sizing: border-box makes padding count inside the declared width, so the container doesn't exceed 100% of its parent. Applying box-sizing: border-box globally with *, *::before, *::after { box-sizing: border-box; } is a common and safe reset that prevents padding from causing overflow.

The overflow audit

Even after converting obvious widths, something usually still overflows. The systematic way to find culprits: in the browser's device emulation, temporarily add a rule like * { outline: 1px solid red; }, or use the browser's element inspector to select elements and watch which one extends past the viewport edge. Common offenders are wide or blocks, large