Guide

Make Your Website Mobile-Friendly with HTML and CSS

Published 28 October 2026 · By Pro Web Developers · 4 min read

In short
  • Use responsive design to adapt your website's layout to different screen sizes and devices.
  • Optimize images to reduce file size and improve loading times on mobile devices.
  • Test your website's mobile performance with Google's PageSpeed Insights tool and follow its suggestions.

To make a website mobile-friendly with HTML and CSS, your layout and content must adapt to different screen sizes and devices. You do this with responsive design techniques. Then you test the result with tools like Google's PageSpeed Insights.

Meta description: Learn how to make a website mobile-friendly with HTML and CSS: responsive layouts, media queries, flexible images and testing with PageSpeed Insights.

What is a mobile-friendly website?

A mobile-friendly website displays and works well on mobile devices such as smartphones and tablets. Its layout, text, images and navigation are easy to use on smaller screens.

Mobile-friendly meansLayout fits the screen sizeLoads fast, even on slow connectionsButtons large enough to tapText readable without zooming
What a mobile-friendly page does on a phone. Our own illustration.

What does mobile-friendly mean?

A mobile-friendly website adapts to different screen sizes and devices and gives visitors a good experience. This includes:

  • Responsive design: The website's layout changes to fit the screen size and orientation.
  • Fast loading times: The website loads quickly, even on slower mobile connections.
  • Easy navigation: Buttons and links are large enough to tap easily.
  • Clear text: Text is large enough to read without zooming on smaller screens.
  • Visual hierarchy: The website's layout and design guide the user's attention to key content.

You can check how your website performs on mobile with Google's PageSpeed Insights tool. This free tool runs a mobile test of your page and suggests improvements.

What causes a website to not be mobile-friendly?

A website may not be mobile-friendly because of several common issues.

Not mobile-friendlycommon causesFixed layoutcontent cut offLarge imagesslow to loadNo testingon small screens
Three common reasons a site fails on phones. Our own illustration.

Inadequate Layouts

Fixed layouts cause problems on smaller screens. A fixed layout does not adapt to different screen sizes, so visitors have a poor experience. A site with a fixed layout may look great on a large desktop screen, but on a phone the content may be cut off or hard to read.

Image Issues

Large images also make a site less mobile-friendly. They take longer to load and can be hard to view on smaller screens. The result is a slow and frustrating experience.

Lack of Testing

Not testing on different screen sizes is another common issue. Without testing, you may not know how your website looks and works on smaller screens. This can lead to a poor user experience and lost customers.

  • Not using responsive design principles
  • Ignoring browser and device compatibility issues
  • Not optimizing images for web use
  • Failing to test on various devices and browsers

Step-by-Step Fix: Making Your Website Mobile-Friendly

Setting Up a Responsive Design

To make your website mobile-friendly, set up a responsive design that adapts to different screen sizes. Use HTML and CSS to build a flexible layout, for example with CSS Grid or Flexbox, that rearranges content and images as the screen size changes.

1Viewport tagin the head2Relative unitsems, rems, %3Testdevices, browsers
The HTML and CSS fix in three steps. Our own illustration.

Using Media Queries

Media queries are a crucial part of responsive design. They let you define different styles for different screen sizes and devices. Use them to adjust font sizes, image sizes and layout settings for mobile devices.

Testing for Mobile-Friendliness

Before you fix anything, test your website on different devices and browsers. Run Google's PageSpeed Insights on your pages for recommendations, and use the device mode in Chrome DevTools to preview different screen sizes.

To fix mobile-friendliness issues, follow these steps:

  • Add the viewport tag <meta name="viewport" content="width=device-width, initial-scale=1"> to your page's head, and set a maximum width for your content and images (for example, max-width: 100% on images).
  • Use relative units like ems, rems or percentages for font sizes and padding.
  • Test your website on different devices and browsers to make sure it looks good on all screens.

Preventing Mobile-Unfriendliness

To prevent mobile-unfriendliness, use responsive design principles from the start. Your website will then adapt to various screen sizes and devices. On a new website, use a grid system and flexible layouts so content is easy to use on any device.

Use Responsive Images

Optimize images to reduce file sizes and speed up page loading. Compress images without visible quality loss so they load quickly on mobile devices. Use the "srcset" attribute to offer different image sizes for different screen widths and resolutions.

  • Test for Different Screen Sizes: Regularly test your website on various devices and screen sizes to make sure it stays mobile-friendly.
  • Use a Mobile-Friendly Theme: Choose a website builder or template designed for mobile screens.
  • Avoid Flash and Java: Modern browsers no longer support Flash or Java applets, so do not use them.
  • Optimize Content for Mobile: Use clear, concise language and make sure your content is easy to read on smaller screens.

For more on what phone visitors see when your website is not mobile-friendly, see Website Not Mobile-Friendly? What Phone Visitors See.

If you would rather hand this job to someone else, it is the kind of work our website services cover.

Frequently asked questions

How do I make my website responsive?

Add the viewport meta tag to your pages. Then use CSS media queries, flexible layouts and relative units, such as percentages or ems, to set the layout and size of elements.

What is a responsive design?

Responsive design is a web design approach where the layout adapts to different screen sizes and devices, so visitors get a good experience on any screen.

Why is mobile-friendliness important?

Many visitors browse on phones. A mobile-friendly site is easy to read and use on small screens, which improves their experience and engagement.

How do I test my website for mobile-friendliness?

Run your pages through Google's PageSpeed Insights, which tests mobile performance and suggests improvements. Also check your site on real phones or with the device mode in Chrome DevTools.

What are the benefits of a mobile-friendly website?

A mobile-friendly website gives visitors a better experience, can improve engagement and can help increase enquiries and sales.

Can I make my website mobile-friendly without coding?

Yes. Website builders such as Wix, Squarespace and Shopify, and many WordPress themes, offer mobile-friendly templates and drag-and-drop editors, so you can build a mobile-friendly site without coding.

Want a free check of your site?

Send us your web address. We'll look at it and tell you in plain English whether it has this problem, what else we notice, and what a fix would involve. Free, with no obligation.

Get a free site check →

Further reading

General advice only: check with your host or developer before changing a live site. How we write.