Making a Free CSS Template Work Well on Phones

Browsing a website on a phone

Pretty much every free CSS template says it’s responsive, meaning the layout should adjust to whatever screen it’s on. Some do that well. Some only sort of do it. So open the demo on your phone before you commit to one, and expect to do a bit of fixing.

It matters for search as well as for visitors. Google uses the mobile version of a site’s content for indexing and ranking, and it calls that mobile first indexing. If your template’s poor on phones, fix it early, before you’ve built the whole site on top of it.

Google’s guidance mentions three ways to serve a site to mobile users: responsive design, dynamic serving and separate mobile URLs. Google recommends responsive web design because it’s the easiest design pattern to implement and maintain. A responsive template uses one set of HTML for every device, and the CSS changes how it’s laid out.

Our guide to mobile SEO factors covers the wider search side. If you’re using a template, though, the main thing is to pick one that’s responsive from the start. Reworking a fixed width layout for phones takes ages.

The quickest test is to open the demo page and drag your browser window narrower. A responsive layout will rearrange columns, menus and images as it shrinks. Then open the same page on your phone. If you have to scroll sideways to read the text, it’s not handling small screens properly.

Viewport and zoom

Open the main HTML file and look in the head section for a meta tag named viewport. It controls how the page is sized on mobile browsers. W3C says desktop browsers ignore the viewport meta element, so it only affects phones and other mobile devices. Most current templates have it already, but check.

While you’re looking at it, make sure it doesn’t stop people zooming. W3C accessibility test rules flag a viewport tag that turns user scaling off. They also flag a maximum scale value below 2, because that stops people zooming to 200 per cent. W3C says most modern mobile browsers ignore these limits or have a setting to allow zoom anyway. Still, leave zoom switched on.

Reflow, and testing at 320 pixels

The Web Content Accessibility Guidelines have a success criterion called Reflow at Level AA. It asks that content can be shown without loss of information or functionality at a width equal to 320 CSS pixels. The point is that nobody should have to scroll in two directions to read something. W3C explains that scrolling back and forth makes people lose their place and adds effort.

You can test this on your desktop computer. W3C says 320 CSS pixels matches a window 1280 CSS pixels wide zoomed to 400 per cent. So set your browser to 400 per cent and scroll down the page. If you have to scroll sideways to read paragraphs, the template needs work. It’s a good width to test at because it catches layout problems early.

Some content gets an exception. W3C lists maps, diagrams, data tables, video and games among the things that may need a layout in both directions. The headings, search fields and other content around them should still reflow, though. Our post on accessible web design principles has other ways to make a site easier to use.

Most of the fixes come from a handful of CSS tools. The W3C techniques listed for reflow keep pointing to the same ones: media queries, CSS grid, flexbox and width limits on images. These are the ones to try first:

  • Media queries that apply different CSS rules once the screen is narrower than a set width.
  • CSS grid or flexbox, so columns can stack into a single column on small screens.
  • A maximum width on images, so pictures shrink to fit their container instead of spilling out.
  • Rules for long web addresses and strings of text, so they wrap and don’t stretch the page.
  • Media queries that stop sticky headers and footers taking up too much of a small screen.

Look for where the template sets fixed widths in pixels, and see if a percentage or a maximum width would work instead. Change one rule at a time and refresh the page on your phone after each one. Keep a copy of the original CSS so you can go back if you break something. It’s much easier to keep track of small edits than one big rewrite.

Same content on both

Some templates hide whole sections on small screens to make the layout fit. Don’t do that. Google says your mobile site should have the same content as your desktop site. Tabs and accordions are fine for keeping things compact, as long as the content inside them matches the desktop version. Google also says not to lazy load primary content only when someone swipes, clicks or types, because its crawler won’t do any of those things.

Keep page titles and meta descriptions the same on both versions too, which is what Google suggests. Images should be high quality, not small or low resolution, and in a supported format. And Google asks for the same alt text on images across mobile and desktop.

Browser tools help, but test on a real phone as well. Tap every menu item and button with your thumb. Check you can read the text without zooming and that the links aren’t crammed too close together. Then turn the phone on its side and do it again.

If the template’s still giving you trouble after all that, look at other options. A drag and drop WordPress theme handles a lot of the responsive layout for you, though you give up some control. Whatever you go with, keep the core web design principles for a new site in mind. A plain layout that reads well on a phone is better for your visitors than a fancy one that doesn’t.