Attempting to optimize a webpage design for compatibility with Google's mobile-friendly testing tool

After much searching on the forum, this is my first post, so I kindly ask for patience!

I am dealing with a 20-year-old website that urgently needs to be optimized for mobile devices. With almost 2200 pages, manual editing is out of the question, so I need to find a simple solution primarily using CSS.

However, even the most basic attempts at making the pages mobile-friendly seem to conflict with Google's requirements and layout preferences. For example, centering the content causes a 'Page is not mobile-friendly' message from Google.

To address these issues, I have rewritten the HTML and temporarily hard-coded the CSS directly onto the page until I can transfer it to a separate style sheet.

I started with a div width of 320px as a reference point for Google's testing. However, when trying to center the content using "margin-left: auto; margin-right: auto;", the mobile test fails. Removing the centring allows the page to pass the test.

Adjusting the div width to 100% and setting the image width to 320px passes the test but sacrifices centering. On larger mobile displays, increasing the image width results in another failure by Google. It feels like a never-ending cycle, and I'm seeking advice on how to proceed.

The code snippet below reflects the current state of the page - centered but triggering a Google fail due to content not fitting the screen.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<base target="_top" />
<meta name="viewport" content="width=device-width, initial-scale=1">

</head>

<body style="text-align: center; overflow-x: hidden;">

<div style="width: 320px; margin-left: auto; margin-right: auto;">

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" id="Popup1">
<tr>
    <td width="100%">
    <img border="0" src="../images/Americas/North/Native_Powhatan_Tribe01_max.jpg" alt="Test" style="max-width: 100%; width: 100%;" height="auto"><!-- Image width is 1000px --></td>
</tr>
</table>

</div>

</body>
</html>

This is the current live version of the page:

For testing purposes, here is the microsite version of the page with all of my modifications:

(The main issue seems to revolve around image sizing and the container, prompting me to strip everything else out temporarily).

Answer №1

BODY has default margin and padding values. To reset them, use margin:0;padding:0 and add width:100% for a full-width fit to the screen.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head>
<meta http-equiv="Content-Language" content="en-gb">
<link rel="stylesheet" type="text/css" href="http://www.historyfiles.co.uk/microsite_live/css/history_mainstyles.css" />
<meta name="ROBOTS" content="noindex, follow" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<base target="_top" /><meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" href="../favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<style type="text/css" media="all" />
@import "http://www.historyfiles.co.uk/microsite_live/css/history_substyles.css";
</style>

</head>
<!-- I modified this line. -->
<body style="width:100%;margin:0;padding:0">

<div style="width:320px;margin:0 auto">

<table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse;" id="Popup1">
<tr>
    <td width="100%">
    <img border="0" src="https://via.placeholder.com/1000x500/4B89DA/F4F6F9" alt="Test" width="100%"><!-- Image width is 1000px --></td>
</tr>
<tr>
    <td width="100%" height="10">
</td>
  </tr>
  <tr>
    <td width="100%">

<p class="popuptitle">Captain John Smith</p>

    </td>
  </tr>
  <tr>
    <td width="100%">

<p class="popup">John Smith is shown in this illustration trading 
with the native Americans who resided close to James Fort, probably 
in 1607-1608, although his explorations took him much further afield, 
    across the northern edge of Chesapeake Bay and into Susquehannock 
    territory.</p>

</td>
</tr>
<tr>
    <td width="100%" height="70">
</td>
</tr>
<tr>
    <td width="100%">

    <p class="popup">Original text copyright © P L Kessler and the 
    History Files. Image copyright © respective copyright holders. 
    An original photo page for the History Files. Go 
    <a href="javascript:history.back()">back</a> or return 
    <a target="_top" href="../index.html">home</a>.</p>

</td>
</tr>
<tr>
    <td width="100%" height="70">
</td>
</tr>
<tr>
<td width="100%" bgcolor="#141414">

<!-- Footer links -->
<p class="navftr" style="margin-bottom: 5px;">Copyright © 1999-2018 <a href='http://www.kessler-web.co.uk/' target='_blank'><span class='navftr'>Kessler Associates.</span></a> All rights reserved.</p>

</td>
</tr>
</table>

</div>

</body>
</html>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the best way to incorporate an exception for the printThis() element?

Is there a way to exclude a specific div from being printed when using the printThis() function? For example: <div id="print-it"> <div>hello</div> <div id="no-print-this"> <button>must be show on page but not print</but ...

Is it possible to incorporate a similar box on a webpage?

I am trying to find a way to add a similar box to a webpage like the one shown in this image. The design I am referring to is from Reddit's theme, but I would like to know how to create a box with a different color and then have another box next to i ...

Adding Logging Features in ASP.NET

I am currently working with an .ascx file that contains both JavaScript and div elements. I need to add a log statement inside a function for troubleshooting purposes. Can someone please guide me on how to achieve this? Below is a snippet of my code: fu ...

"Is there a way to implement a sequence of fadeIn() followed by fadeOut() and then insertAfter

I have created a simple div fade cycle. Some of the divs are within an outer div, which is then placed in another outer div. I've written a script that cycles through these divs by fading them in and out. However, there seems to be a problem - the div ...

The collapsible navbar vanished, where did it go?

While experimenting with the carousel template page, I noticed that the NavBar collapses when the screen width is reduced below a certain pixel size. Initially, everything was working fine as intended. However, after making some modifications to the carou ...

Unable to load variables into site.css in order for Flask app to successfully render home.html

I'm encountering difficulties in getting my site.css file to accept two variables passed in from my app.py using Jinja2 templates, namely {{ variable }}. In app.py, I have defined two variables named empty_fill_line and fill_line, which dynamically up ...

Having trouble making an HTML5 video work on Android? It seems to play fine when clicking the play button,

It has come to my attention that html5 video on Android devices is unable to autoplay. Currently, the video only plays on the device when the user manually clicks on the play button. <video width="640px" height="360px" src="media/video/Moments_of_Every ...

Adaptive design exhibits varying appearances across various screen sizes

Currently, I am working on a responsive design WordPress site and here is the markup: <div class="contact-wrap"> <div class="contact-number">123-456-7890</div><!--.contact-number--> <div class="user-login"><a href="#"& ...

Is there a advantage to using Angular's component style encapsulation for improved performance?

Recently, I came across the styling methods of Angular 2 which allows you to directly include your styles within the component. If you want to explore more on this topic, check out loading styles. There are two options for style encapsulation in Angular 2 ...

Updating content with jQuery based on radio button selection

Looking for assistance with a simple jQuery code that will display different content when different radio buttons are clicked. Check out the code here. This is the HTML code: <label class="radio inline"> <input id="up_radio" type="radio" n ...

Different ways to contrast rows within ag-grid

I am in the process of comparing two identical rows within my ag-grid and emphasizing any variances between them. While most column values are matching, I wish to highlight any cell that differs from the previous row. Is there a means to achieve this in ...

Organize object properties based on shared values using JavaScript

Check out the JavaScript code snippet below by visiting this fiddle. var name = ["Ted", "Sarah", "Nancy", "Ted", "Sarah", "Nancy"]; var prodID = [111, 222, 222, 222, 222, 222]; var prodName = ["milk", "juice", "juice", "juice", "juice", "juice ...

How come I can't see this on my display?

I'm facing an issue with this particular HTML snippet not displaying when I view the file in Chrome or any other browser. Below is the code: <!DOCTYPE html> <html> <head> <title> # <title& ...

Issue with updating Angular list reference when deleting an item

My current task involves implementing a feature that displays selected items from a hierarchical structure on the right side. slice.component.ts : import { Component, Input, OnInit, ChangeDetectionStrategy, ChangeDetectorRef } from '@angular/core&a ...

Integrating a title field into every p-column with ng-template

I am exploring ng-templates for the first time. I have managed to customize each column to display names accurately, but I am encountering an issue. I would like to incorporate a title field in order to show a tooltip with the full name when hovering over ...

Using a DIV to contain a FileUpload Control in an ASPX page

Scenario: I have an ASPX page (Page A) without a form element, which contains a DIV displaying another ASPX page (Page B) with a FileUpload Control inside a form element. Requirement: Submit the form to upload the file without refreshing or navigating awa ...

One way to change the cursor CSS property is by dynamically altering it based on scrolling behavior. This involves modifying the cursor property when scrolling

I'm attempting to adjust the cursor property within an Angular function. The issue I'm facing is that when I begin scrolling the webpage, the cursor changes to a pointer, but when I stop scrolling, it remains as a pointer. I've attempted to ...

Modifying table background color using AJAX and jQuery?

Scenario: My web page is designed to automatically search for a specific cell input by the user. If the cell has been input with a value, the table's background color will turn red; otherwise, it will remain green. Currently, the table has not been p ...

Ensure that the following div remains positioned beneath the current one

After reading through this question on Stack Overflow, about creating a responsive table with both vertical and horizontal headers, I came across this particular issue, demonstrated in this codepen example: Currently, the second table appears directly bel ...

Choose the initial search result without actually opening it using jQuery

I am working on an HTML file that contains multiple input fields, which get automatically filled when a corresponding item is selected from the auto-complete feature. Here is a snippet of my HTML code: <table class="table table-bordered"> <u ...