EthicsComputerCourses
Join training +91 90532 10052

Cross-Device Compatibility Testing

HTML · Lesson 205 of 234 Advanced 11 min read Updated

By the end of this lesson you will be able to build a device and browser matrix for Indian users, know the limits of DevTools device mode, debug a page on a real Android phone or iPhone from your computer, and check touch, zoom and orientation with a diagnostic page you build yourself.

What you should know first: Cross-Browser Compatibility, Browser Developer Tools: Advanced and Playwright Browser Testing. Layout checks at many widths come next, in Responsive Website QA. Menu names were checked against the official Chrome, Android and Apple documentation in November 2026.

Why devices behave differently

Many things change from one device to another:

  • Screen: size and device pixel ratio (DPR), the physical pixels per CSS pixel.
  • Input: a finger is large and cannot hover; a mouse is precise and can.
  • Power: a budget phone runs heavy JavaScript much more slowly.
  • Network: mobile data in a moving train is slower than office Wi-Fi.
  • Engine: Chrome on Android uses Blink. Every iPhone browser, even "Chrome", uses WebKit.
  • User settings: larger system font, dark mode, reduced motion, data saver.
  • In-app browsers: links opened inside chat and social apps load in a built-in WebView with its own quirks.

Testing a new Lucknow bus route in an empty car at midnight proves little. The real test is a full bus at 9 am in the rain.

A device and browser matrix for India

In India, most visitors to a typical consumer site use Android phones with Chrome, many of them budget models. iPhone Safari users are fewer but often important for shopping and banking. Desktop matters more for office tools and student portals.

This varies by site, so do not copy anyone's percentages. Build your matrix, a table of the combinations you promise to test, from your own analytics:

TierExample combinationWhyWhen to test
1Chrome on a budget Android phone, mobile dataThe most common real visitorEvery release, by hand
1Safari on an iPhoneWebKit-only bugs; no other way to see themEvery release
1Chrome or Edge on Windows, 1366 px wideOffice and cyber-cafe usersEvery release
2Samsung Internet, Firefox on AndroidDifferent engines or defaultsMajor releases
2An in-app WebView (open a shared link)Missing features, odd back buttonMajor releases
3Tablet, landscape; old Android with an outdated browserEdge casesBefore big launches

For more combinations, use pairwise selection from Mobile Testing & Appium.

Step 1: a device info page for testers

"The button is cut off on my phone" always leads to "which phone, which browser, what size?". This page answers that. Open it on each device and paste its report into your bug reports.

HTMLOpen in editor
<!DOCTYPE html>
<html lang="en-IN">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Device info for testers</title>
  <style>
    body { font-family: system-ui, sans-serif; margin: 16px; }
    table { border-collapse: collapse; width: 100%; max-width: 36rem; }
    th, td { border: 1px solid #bbb; padding: 4px 8px; text-align: left; }
    th { width: 45%; font-weight: 600; }
    pre { background: #f4f4f4; padding: 8px; white-space: pre-wrap; }
  </style>
</head>
<body>
  <h1>Device info</h1>
  <p>Open this page on each test device. It updates when you rotate, resize or zoom.</p>
  <table><tbody id="info"></tbody></table>
  <h2>Copy into your bug report</h2>
  <pre id="text"></pre>

  <script>
    const mq = (query) => matchMedia(query).matches;
    const notShared = "not shared by this browser";

    function readDevice() {
      const vv = window.visualViewport;
      const conn = navigator.connection;
      return [
        ["Viewport (CSS px)", `${innerWidth} x ${innerHeight}`],
        ["Visual viewport and zoom", vv ? `${Math.round(vv.width)} x ${Math.round(vv.height)}, zoom ${vv.scale.toFixed(2)}` : notShared],
        ["Screen (CSS px)", `${screen.width} x ${screen.height}`],
        ["Device pixel ratio", String(devicePixelRatio)],
        ["Orientation", screen.orientation ? screen.orientation.type : (mq("(orientation: portrait)") ? "portrait" : "landscape")],
        ["Primary pointer", mq("(pointer: coarse)") ? "coarse (finger)" : mq("(pointer: fine)") ? "fine (mouse or stylus)" : "none"],
        ["Primary input can hover", mq("(hover: hover)") ? "yes" : "no"],
        ["Any coarse pointer available", mq("(any-pointer: coarse)") ? "yes" : "no"],
        ["Max touch points", String(navigator.maxTouchPoints)],
        ["prefers-reduced-motion", mq("(prefers-reduced-motion: reduce)") ? "reduce" : "no-preference"],
        ["prefers-color-scheme", mq("(prefers-color-scheme: dark)") ? "dark" : "light"],
        ["CPU threads", String(navigator.hardwareConcurrency ?? notShared)],
        ["Memory (GB, rounded)", navigator.deviceMemory ? String(navigator.deviceMemory) : notShared],
        ["Network estimate", conn ? `${conn.effectiveType}, data saver ${conn.saveData ? "on" : "off"}` : notShared]
      ];
    }

    function render() {
      const rows = readDevice();
      const tbody = document.querySelector("#info");
      tbody.replaceChildren();
      for (const [label, value] of rows) {
        const tr = tbody.insertRow();
        const th = document.createElement("th");
        th.scope = "row";
        th.textContent = label;
        tr.append(th);
        tr.insertCell().textContent = value;
      }
      document.querySelector("#text").textContent =
        rows.map(([label, value]) => `${label}: ${value}`).join("\n") + `\nUser agent: ${navigator.userAgent}`;
    }

    render();
    addEventListener("resize", render);
    window.visualViewport?.addEventListener("resize", render);
    screen.orientation?.addEventListener("change", render);
    for (const q of ["(pointer: coarse)", "(hover: hover)", "(prefers-reduced-motion: reduce)", "(prefers-color-scheme: dark)"]) {
      matchMedia(q).addEventListener("change", render);
    }
  </script>
</body>
</html>

A laptop shows a fine pointer, hover "yes" and zero touch points. A phone shows a coarse pointer, hover "no" and usually a DPR of 2 or more. Memory and network estimates exist only in Chromium browsers, so Safari and Firefox show "not shared by this browser".

Use the same pointer and hover media queries in CSS: @media (hover: hover) adds hover effects only where hover exists, so phone users never meet a menu that opens only on hover.

DevTools device mode and its limits

Chrome's device mode (the Toggle device toolbar button) resizes the viewport, sets a DPR, sends a mobile user agent and turns clicks into touch events. Chrome's documentation calls it a "first-order approximation". We loaded the device info page in Playwright with the "Pixel 7" profile, which uses the same emulation:

Output
Viewport (CSS px): 412 x 839
Device pixel ratio: 2.625
Orientation: portrait-primary
Primary pointer: coarse (finger)
Primary input can hover: no
Max touch points: 1
CPU threads: 8
Memory (GB, rounded): 16
User agent: Mozilla/5.0 (Linux; Android 14; Pixel 7) ... Chrome/159.0.8154.6 Mobile Safari/537.36

Size, DPR and pointer look like a phone, but CPU threads and memory are still the laptop's. Emulation does not slow the processor, show the real address bar (which changes viewport height as it hides), open the phone's keyboard over your form, or change fonts. "iPhone" presets still run Blink, never WebKit. Find layout bugs here, then confirm on real devices.

Throttling: slow networks and slow CPUs

The Network panel's throttling presets, shown in Browser Developer Tools: Advanced, include Fast 4G, Slow 4G, 3G and Offline. Check that loading states appear and buttons do not double-submit while waiting.

For CPU, choose a slowdown such as 4x or 6x in the Performance panel's capture settings, then open menus and type in search boxes. If it lags at 6x, users of cheaper phones feel it. Both are estimates; real mobile data on a real device is the final judge.

Remote debugging a real Android phone

Steps checked against the Chrome and Android developer documentation:

  1. On the phone, open Settings > About phone and tap Build number seven times until you see "You are now a developer!". The path differs by maker; on Samsung it is under Software information.
  2. Go back to Settings, open Developer options (under System on recent versions) and turn on USB debugging.
  3. On your computer, open Chrome and go to chrome://inspect#devices. Make sure Discover USB devices is ticked.
  4. Connect the phone with a USB cable, directly rather than through a hub. On Windows you may need the maker's USB driver.
  5. The phone asks whether to allow USB debugging. Allow it. The phone's model name appears on chrome://inspect.
  6. Open your page in Chrome on the phone and click Inspect next to it. A full DevTools window opens for the page on the real hardware.

To open your local development server on the phone, click Port forwarding next to Discover USB devices, tick Enable port forwarding, add your port (for example 3000 and localhost:3000) and click Done. Then visit localhost:3000 in Chrome on the phone.

Remote debugging an iPhone or iPad

Safari's Web Inspector does the same, but needs a Mac. Steps checked against Apple's Safari documentation:

  1. On the iPhone, open Settings > Apps > Safari > Advanced and turn on Web Inspector. (Before iOS 18, the path was Settings > Safari > Advanced.)
  2. On the Mac, open Safari, choose Safari > Settings > Advanced and tick Show features for web developers. A Develop menu appears.
  3. Connect the iPhone to the Mac with a cable. If the iPhone asks whether to trust this computer, tap Trust.
  4. Open your page in Safari on the iPhone.
  5. On the Mac, open the Develop menu, choose your iPhone's name and then the page. A Web Inspector window opens for that tab.
  6. Optional: after the first cable connection, choose Connect via Network from the device's submenu to inspect over Wi-Fi.

Without a Mac, test by hand on a borrowed iPhone or use a cloud lab.

Cloud device labs

A cloud device lab rents you real phones and browsers in a data centre, controlled from your browser. Examples include BrowserStack, Sauce Labs and AWS Device Farm (examples, not recommendations). Most accept Selenium or Playwright connections too, as in Selenium Web Testing. They help with iPhones and rare devices, but their fast data-centre networks are not Indian mobile data.

Step 2: testing touch, zoom and orientation

Touch, zoom and rotation cause bugs a mouse never finds. This tester measures buttons against WCAG 2.2 target size (24 by 24 CSS pixels for Level AA; 44 by 44 is the stricter AAA size) and logs which pointer pressed them.

HTMLOpen in editor
<!DOCTYPE html>
<html lang="en-IN">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Touch and target size tester</title>
  <style>
    body { font-family: system-ui, sans-serif; margin: 16px; }
    .row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
    button { box-sizing: border-box; font: inherit; }
    .tiny { width: 16px; height: 16px; padding: 0; font-size: 12px; line-height: 1; }
    .mid { min-width: 28px; height: 28px; padding: 0 6px; }
    .big { min-height: 48px; padding: 0 16px; }
    table { border-collapse: collapse; margin-top: 12px; }
    th, td { border: 1px solid #bbb; padding: 4px 8px; text-align: left; }
    .bad { background: #ffebee; }
  </style>
</head>
<body>
  <h1>Touch and target size tester</h1>
  <div class="row">
    <button class="tiny" aria-label="Remove item">x</button>
    <button class="mid">Add</button>
    <button class="big">Book trial</button>
  </div>

  <table>
    <thead><tr><th scope="col">Button</th><th scope="col">Size (CSS px)</th><th scope="col">24 x 24 minimum</th><th scope="col">44 x 44 comfortable</th></tr></thead>
    <tbody id="sizes"></tbody>
  </table>

  <h2>Input log</h2>
  <ul id="log"></ul>

  <script>
    const log = (text) => {
      const li = document.createElement("li");
      li.textContent = text;
      document.querySelector("#log").prepend(li);
    };

    // 1. Measure every button against the WCAG 2.2 target sizes
    function measure() {
      const tbody = document.querySelector("#sizes");
      tbody.replaceChildren();
      for (const b of document.querySelectorAll(".row button")) {
        const { width, height } = b.getBoundingClientRect();
        const min = width >= 24 && height >= 24;
        const comfy = width >= 44 && height >= 44;
        const tr = tbody.insertRow();
        if (!min) tr.className = "bad";
        for (const text of [b.getAttribute("aria-label") || b.textContent,
                            `${Math.round(width)} x ${Math.round(height)}`,
                            min ? "pass" : "FAIL", comfy ? "pass" : "too small"]) {
          tr.insertCell().textContent = text;
        }
      }
    }
    measure();

    // 2. Which kind of pointer pressed the button?
    document.querySelector(".row").addEventListener("pointerdown", (event) => {
      const b = event.target.closest("button");
      if (b) log(`${event.pointerType} pressed "${b.getAttribute("aria-label") || b.textContent}"`);
    });

    // 3. Pinch zoom and rotation
    window.visualViewport?.addEventListener("resize", () =>
      log(`Visual viewport now ${Math.round(visualViewport.width)} px wide, zoom ${visualViewport.scale.toFixed(2)}`));
    screen.orientation?.addEventListener("change", () => {
      log(`Orientation changed to ${screen.orientation.type}`);
      measure();
    });
  </script>
</body>
</html>

"Remove item" (16 x 16) fails the minimum, "Add" passes only the minimum and "Book trial" passes both. A mouse click logs mouse pressed; a tap in device mode or on a phone logs touch pressed. On a phone, pinch and rotate to see the other log lines.

Add these checks to every real-device session:

  1. Tap every control with a thumb. Small or crowded targets cause wrong taps.
  2. Pinch-zoom to 200%. Never ship user-scalable=no or maximum-scale=1; they block zoom for people who need it.
  3. Increase the system font size and reload. Text should grow without overlapping.
  4. Rotate in the middle of a form. Typed data must stay, and nothing may hide behind the keyboard.
  5. Turn on reduced motion and check that big animations stop.

Common mistakes

  • Trusting device mode alone. It does not slow the CPU, show the real keyboard or use Safari's engine.
  • Testing only on your own new phone. An older, cheaper Android phone reveals slow scripts at once.
  • Testing only on office Wi-Fi. Use throttling, then real mobile data.
  • Hover-only menus. Phones cannot hover; use (hover: hover) for extras, not for core features.

Interview questions

1. Why is Chrome DevTools device mode not enough for mobile testing?

It emulates viewport, DPR, user agent and touch, but runs on the laptop's CPU and memory, without the real browser UI or keyboard. Its iPhone presets still use Blink, not WebKit. Real devices are needed for performance, keyboard and engine bugs.

2. How do you debug a page on a real Android phone?

Enable Developer options and USB debugging on the phone, connect it by USB, open chrome://inspect#devices on the computer with "Discover USB devices" ticked, allow the prompt on the phone, then click Inspect next to the open tab. Port forwarding lets the phone open a localhost server.

3. How would you choose which devices to test?

Start from the site's analytics: top browsers, devices and screen widths. Group them into tiers and test the most common every release. Always include a budget Android phone, an iPhone for WebKit and an in-app browser.

4. What do the pointer and hover media queries tell you?

pointer describes how precise the primary input is: fine for a mouse, coarse for a finger. hover says whether the primary input can hover. Together they let CSS enlarge targets for touch and add hover effects only where hover exists.

Key points

  • Devices differ in screen, input, CPU, memory, network, engine and user settings, not just width.
  • Build your test matrix from your own analytics; in India, prioritise budget Android phones with Chrome, plus iPhone Safari.
  • Device mode is a first-order approximation: great for layout, blind to real CPU, keyboard and WebKit bugs.
  • Remote debugging gives full DevTools on a real Android phone (chrome://inspect) or iPhone (Safari Web Inspector on a Mac).
  • Throttle network and CPU for a rough estimate, then confirm on real mobile data.
  • Test touch targets (24 x 24 minimum), zoom to 200%, larger system fonts and rotation mid-task.

Exercise

Run a small cross-device test on a page you built earlier, such as your portfolio:

  1. Write a matrix of 5 device and browser combinations, with a tier and a reason for each.
  2. Open the device info page from Step 1 on at least two real devices and save both reports.
  3. Remote debug the page on one real phone and record one console message or measurement.
  4. Run the four touch, zoom and rotation checks and write one bug report that includes the device info text.
Show solution

A sample matrix and bug report:

Text
Matrix: Portfolio site (from our analytics)
T1  Chrome, budget Android phone, mobile data   most visitors
T1  Safari, iPhone                              WebKit-only bugs
T1  Chrome, Windows laptop 1366 px              recruiters on office PCs
T2  Samsung Internet, Android                   different defaults
T2  In-app browser (link shared in a chat app)  WebView quirks

Bug: Contact form "Send" button hidden behind keyboard in landscape
Steps: 1. Open /contact  2. Rotate to landscape  3. Tap the Message field
Expected: The Send button can be scrolled into view while typing
Actual: The keyboard covers the button and the page cannot scroll further
Device info: Viewport 732 x 189, DPR 2.75, landscape-primary,
             pointer coarse, hover no, Chrome on Android

The device info text tells the developer which size and input type to reproduce in device mode before confirming the fix on the real phone.

Quick Quiz

1. Which statement about an "iPhone" preset in Chrome device mode is true?

2. Where do you start remote debugging an Android phone in desktop Chrome?

3. A menu opens only on hover. Which media query helps you avoid trapping phone users?

4. What is the WCAG 2.2 Level AA minimum target size?

Learn HTML with a mentor

Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.

  • Project-based learning
  • Mentor code reviews
  • Free counselling call