| 3:04 PM IST
HTML Website Looks Wrong on Mobile: How to Find the Layout Problem
Tech

HTML Website Looks Wrong on Mobile: How to Find the Layout Problem

Tiny text, sideways scrolling or overlapping buttons on phones? How to find the exact element breaking your HTML website’s mobile layout.

By · 5 min read 0 views Rate it 0 comments

Short answer: When an HTML website looks wrong on mobile, check three things: a correct viewport meta tag, any element wider than the screen, and whether your CSS media queries apply. Browser developer tools can help identify elements and rules that need investigation.

Step 1

Check the viewport

Step 2

Locate overflowing elements

Step 3

Test real mobile interactions

Last reviewed: 30 October 2026. Guidance follows web.dev’s “Responsive web design basics” and MDN documentation.

What do you see?

Typical symptoms include text that looks tiny and needs zooming, a page that scrolls sideways, buttons that overlap, images spilling off the edge, or a menu that covers the content and will not close. Sometimes the page looks fine on one phone and broken on another.

What normally happens behind the scenes?

A phone browser needs to know how wide to treat the page. Without instructions, mobile browsers assume a desktop-sized layout of about 980 pixels and shrink it to fit the screen, which makes text unreadable. The viewport meta tag tells the browser to use the device’s real width instead. Once that is set, CSS media queries can switch to mobile-friendly styles at chosen widths.

Also readWebsite Broken After a WordPress Update? A Safe Recovery Checklist

Symptom, cause and check

SymptomLikely causeCheck
Whole page tiny, needs zoomingMissing or wrong viewport tagView source, search for “viewport”
Page scrolls sidewaysOne element wider than the screenDeveloper tools element inspection
Desktop layout on phonesMedia queries missing or not matchingStyles panel at a 375 px width
Images overflowFixed width in HTML or CSSLook for width="1200" or width: 1200px
Fine on one phone onlyBreakpoint gap, or caching of old CSSTest several widths and hard-refresh

Before you change anything

Download a copy of the current HTML and CSS files, or use your host’s backup. If the site is in Git, create a branch. Make changes to a copy first and preview them locally or on a test URL, because a CSS change that fixes one page can affect every page that shares the stylesheet.

Safe checks, in order

1. Confirm the viewport tag

Open the page source and look inside <head>. web.dev recommends this tag for responsive pages:

<meta name="viewport" content="width=device-width, initial-scale=1">

It must appear once, in the head, on every page. Avoid adding user-scalable=no or maximum-scale=1, because those stop people from zooming, which harms accessibility.

2. Use device mode in developer tools

In Chrome or Edge, press F12 and click the device icon. Choose a common phone width such as 360 or 390 pixels. Scroll the page and watch for horizontal scrolling. This is faster than testing on a real phone, although you should test on one at the end.

3. Find the element that is too wide

If the page scrolls sideways, something is wider than the screen. In the Console, paste this short snippet to list the culprits:

document.querySelectorAll('*').forEach(e=>{if(e.scrollWidth>document.documentElement.clientWidth)console.log(e)})

Common offenders are large images, tables, embedded videos and maps, long unbroken links, and containers with a fixed width in pixels.

4. Make media flexible

For images and videos, a widely used rule is:

img, video { max-width: 100%; height: auto; }
/* Give iframe embeds an intentional aspect ratio or responsive wrapper. */

For wide tables, wrap them in a container with overflow-x: auto so only the table scrolls, not the whole page. Replace fixed widths such as width: 1100px with max-width: 1100px; width: 100%.

5. Check your media queries

In the Styles panel, confirm that your mobile rules are actually applied at the phone width. A typo, a missing closing brace or another cascade rule can prevent the expected result. Order matters when origin, importance, cascade layer and specificity are otherwise equal.

6. Clear caches and retest

Phones and CDNs may hold the old stylesheet. Add a version number to the CSS link, for example style.css?v=2, or purge the CDN cache, then reload.

What does success look like?

At 360 to 430 pixels wide there is no sideways scrolling, text is readable without zooming, tap targets are comfortably sized, and forms and menus work. Run Lighthouse in Chrome developer tools, which flags a missing or incorrect viewport tag.

Fix or workaround?

Setting overflow-x: hidden on the body hides the symptom but can cut off content and buttons. Treat it as a temporary workaround. The fix is to correct the element that is too wide.

When should you stop and ask for help?

Ask for help if the layout uses old table-based design, if several pages share tangled CSS, if JavaScript builds the layout, or if a fix on one page keeps breaking another. In those cases a structured responsive update may be cheaper than repeated patches.

How to prevent it happening again

  • Write CSS for small screens first, then add wider breakpoints.
  • Avoid fixed pixel widths for containers and media.
  • Test new content, especially tables and embeds, at phone width before publishing.
Also readElementor Stuck on Loading? Safe Checks Before Changing Your Website

Her View

Most visitors from WhatsApp or Instagram will see your site on a phone first. A quick weekly look at your key pages on your own phone catches problems before customers notice them.

His Insight

Overflow can come from one oversized element or several interacting rules. Use developer tools to identify the cause before rewriting a shared stylesheet. Test the repair across affected pages, since a quick visual fix can hide a second issue.

Related reading: Mobile-first design explained, Core Web Vitals explained and landing page or full website.

HView Digital Solutions

Layout still breaking on phones?

Send us the page link and a screenshot. We can find the element causing the overflow and fix it without disturbing the desktop design.

Clearly scoped small fixes from ₹499.

Describe your problem

Frequently asked questions

Do I need a separate mobile website?

No. A responsive design serves one set of pages that adapt to screen size, which is simpler to maintain.

Why does my site look fine in a narrowed desktop window?

Narrowing a desktop window does not fully mimic a phone. Use device mode and test on a real phone.

Does a broken mobile layout affect Google?

Google mainly uses the mobile version of pages for indexing, so a poor mobile experience can affect how your pages perform.

Sources

Topics: Tech
Harika Behara

Writes for H View, where every story follows our editorial policy and is reviewed before it is published.

All stories by Harika →

H View stories follow our editorial policy. Spotted an error? Tell us and we will correct it.

Rate this article

One tap is enough. No comment needed.

Your rating
Be the first to rate it.

Was this article helpful?

Your answer goes straight to our editors.

Comments0

Be kind and stay on topic. Comments with links are checked before they appear.

No comments yet. Start the conversation.

The H View Brief

Our best stories, in your inbox.

The week’s best Her View, His Insight reading in one short, useful note.

Free. We only use your email to send The H View Brief. Unsubscribe any time.