What a User-Agent Switch Does in Mobile Testing
Updated November 2026. Resizing a page on a phone shows you how CSS media queries behave at a given width. It does not always show you the page that a desktop or tablet browser would have been sent in the first place. Some sites still choose a layout, a redirect or a script bundle after reading the browser’s identity string. That is why testers ask what a user-agent switch does in mobile website testing, and why a width preset alone can be the wrong experiment.
This guide explains the User-Agent request header in plain language, when switching it changes what you see, when it does not, and how to combine it with a forced layout width and a live viewport readout. The working example is Dev Browser, a free Android browser from My Advisers built for responsive testing, code viewing and SEO checks. The official product guide is at myadvisers.in/dev-browser. It lists desktop and tablet user agents, five width presets (390, 820, 1366, 1920 and 2560 pixels) plus custom widths, forced layout width, and a live viewport width readout, among other tools.
The official description of the header itself is on MDN’s User-Agent page: a request header that lets the server and network peers identify the application, operating system, vendor and version of the requesting user agent. Treat that document as the technical source. This article is about using the idea on a phone, not about inventing new header formats.
What a user-agent switch does in mobile website testing
Every ordinary page request includes a User-Agent string. A phone browser’s string typically identifies a mobile OS and a mobile browser. A laptop’s string identifies a desktop OS and a desktop browser. Most modern sites ignore the difference and rely on the viewport width, the viewport meta tag and CSS. A minority still branch on the string. They may:
- serve a separate “mobile” template with fewer columns, a different navigation, or a reduced image set;
- redirect a mobile user agent to an m-dot host, or redirect a desktop user agent away from one;
- load a different JavaScript bundle, or skip a feature they consider desktop-only;
- change consent, paywall or app-install prompts based on the device they think you are using.
A user-agent switch tells the server, for that session, that you are (for example) a desktop or tablet browser, even though you are physically on a phone. Dev Browser’s official feature list describes this simply: desktop and tablet user agents show you what a tablet or desktop visitor receives, not just a resized phone page. That is the job. It is not a change of screen size by itself, and it is not a login, a cookie, or a new IP address.
If you only drag the layout narrower on a phone while still sending a mobile user agent, you are testing responsive CSS. If you only switch the user agent while the page is still laid out at a 390-pixel phone width, you may be given a desktop HTML document that then has to squeeze into a phone viewport. Both tests are useful. They answer different questions. Running only one of them, and then reporting “the desktop site is broken on mobile”, is how teams argue past each other.
User agent, viewport width and forced layout width
Three controls should be kept distinct in a test note.
- The viewport is the visible width in which the page is laid out. Responsive CSS usually follows this width. Dev Browser shows a live viewport width readout so you can record the exact point at which a layout breaks.
- Width presets and custom widths set that layout width. The official presets are Mobile 390, Tablet 820, Laptop 1366, Desktop 1920 and Wide 2560, plus custom values. These are testing widths, not a claim that every phone in India is 390 pixels wide.
- Forced layout width, in the official feature list, forces the page to lay out at the width you chose. That helps with sites that do not respond to a simple resize — a common problem when a page is a fixed-width desktop design, or when the viewport meta tag is missing or wrong.
- The user agent is the identity string sent with the request. It can change which document or redirect you receive, before CSS ever runs.
A clean experiment changes one of these at a time, then combines them on purpose. A typical sequence on a suspected “desktop-only” site is:
- Open the page with the default mobile user agent at the 390-pixel preset. Note the URL, the heading, the navigation and the live width.
- Switch to the desktop user agent, keep the width at 390, and reload. If the HTML, the URL or the navigation changes, the site is branching on the user agent, not only on width.
- Keep the desktop user agent and move the width to 1366 or 1920, with forced layout width if a simple resize is ignored. This is closer to what a laptop user actually sees.
- Repeat with the tablet user agent and the 820-pixel preset if a tablet-specific template is in play.
Write down the combination you used. “Broken on mobile” is not a reproducible report. “Desktop user agent, forced width 1920, heading overlaps the cart icon; same page at mobile user agent and 390 is fine” is a report a developer can act on.
When switching the user agent will not help
Plenty of bugs are pure CSS. A column that overflows at 400 pixels will still overflow if you change only the User-Agent string. Media queries, container queries and container widths do not read that header. In those cases, step the live width through the breakpoint you care about and leave the user agent alone until you have a reason to change it.
A switch also will not reproduce every aspect of a real laptop visit. It does not turn a phone screen into a 15-inch display, it does not create a hardware keyboard, and it does not claim to spoof other fingerprints (TLS, client hints, or cookies you already have). Client hints and site-specific scripts can still detect a mobile environment even after a User-Agent change. If a site still serves the mobile template, record that fact rather than forcing the tool to pretend it is a perfect disguise. The point is diagnostic, not evasion.
Logins and personalisation add another layer. If you are already cookied as a mobile app-install visitor, changing the user agent mid-session may not reset that state. Try a private tab when you need a first-visit view. Dev Browser includes private tabs in its official basics; use them when a sticky cookie is polluting the test.
A practical workflow on Android
- Install Dev Browser from Google Play and open the page you need to test. A short tour of My Advisers’ other tools is in the tools guide on this blog.
- Confirm the viewport meta tag and the live width before you change anything else. If the page looks zoomed out and tiny, the official troubleshooting note in the product guide is that the viewport meta tag may be missing or incorrect. Fixing that is a site change; the browser can only show you the symptom.
- Use a width preset that matches the question, not the one you like visually. 390 for a compact phone, 820 for a tablet-sized layout, 1366 or 1920 for a laptop or desktop, 2560 if you need a very wide monitor check, or a custom width for a reported breakpoint such as 768.
- Switch the user agent only after you have a baseline. Desktop first if the report is “works on a laptop, fails on a phone”, tablet if the report mentions an iPad-style or Android-tablet layout. Reload after the switch so the server sees the new header.
- Turn on forced layout width when the page ignores a simple resize, then read the live width to confirm the layout is actually at the number you intended.
- Optional: run the SEO inspector if the mobile and desktop documents might differ in title, headings or metadata, which some UA-branched sites still do. The official guide includes an SEO inspector and a shareable report; use that if your question is “did we get a different document?”, not only “did the CSS move?”.
Orientation lock and full screen, also listed officially, are supporting controls: they stop the phone rotating mid-test and hide browser chrome when you are judging a design. They are not substitutes for the user-agent switch.
What to write in a bug report
Good mobile-web reports make the next person able to see the same thing without a call. Include:
- the exact URL after any redirect (UA-based redirects are easy to miss if you only paste the starting address);
- the user agent you selected (default mobile, desktop, or tablet);
- the layout width, whether it was forced, and the live readout;
- orientation, if it matters;
- whether you were signed in, and whether you used a private tab;
- a short description of the broken element, and one screenshot at that combination plus one at a combination that works, if you have it.
If the site is one you are still building, test the staging host as well as production. A desktop-only CSS file that is concatenated differently in production is a common surprise. If you are choosing a no-code or hosted builder, remember that some builders still ship different mobile and desktop editors; the no-code builders article on this blog is about that landscape, and a user-agent test is how you check what their published pages actually send.
Mistakes that make a user-agent test misleading
- Changing the user agent and the width at the same time and then not knowing which change caused the new layout.
- Forgetting to reload after a switch, so you are still looking at a document fetched with the old header.
- Reporting a CSS overflow as a “user-agent bug” because the switch was turned on and left on from a previous test.
- Assuming every site still sniffs the User-Agent string. Many do not. Prove it with the four-step sequence above.
- Treating a switch as a privacy or security feature. It is a testing control. It does not anonymise you.
- Quoting a width without the live readout. A preset you tapped is not always the width the page used, especially without forced layout width.
A short worked walk-through
Suppose a client writes that “the shop menu is fine on a laptop but the hamburger never opens on a phone.” Open the staging URL in Dev Browser at the 390-pixel preset with the default mobile user agent. If the hamburger is present and the click target is too small, you are probably looking at a CSS or hit-area problem; a user-agent switch will not be the first fix. If instead you are redirected to a different host, or you see a desktop top-nav squeezed into a narrow column and the hamburger is missing, switch to the desktop user agent, reload, and compare the document. Then set a 1920-pixel forced width with the desktop user agent still on, to confirm that the laptop view the client described is the one you now have. You now know whether to file a mobile-CSS bug, a redirect bug, or a “desktop HTML served into a phone viewport” bug — three different tickets.
The same sequence is useful when you are checking a marketing landing page that was edited only in a desktop builder view. Load the published URL, not only the editor preview. If the desktop user agent at 1920 looks correct and the mobile user agent at 390 drops a form field or a required disclaimer, the published mobile template is the artefact to fix. Capture the SEO inspector report as well if the title or heading in the mobile document differs from the desktop one, because that difference will show up in search results on phones.
Frequently asked questions
Is a user-agent switch the same as “Request desktop site”?
It is the same family of idea: you ask the server to treat you as a desktop browser. A dedicated testing browser is useful when you also need a known width, a forced layout, and a live readout, which a simple desktop-site toggle in a general browser may not give you together.
Do CSS media queries read the User-Agent header?
No. Media queries follow viewport and device features. The header is read, if at all, by the server or by JavaScript. That is why you test both.
Which width preset should I use with a desktop user agent?
Use a desktop width (1366 or 1920 is the usual starting pair) when you want to see the desktop layout as a laptop user would. Use a phone width with a desktop user agent only when you are specifically checking what happens if desktop HTML is forced into a narrow viewport.
Can I type an arbitrary user-agent string in this article’s workflow?
This article only describes the official Dev Browser feature: desktop and tablet user agents. It does not invent a custom-string interface. If a later version of the app offers more, follow the in-app labels and the product guide.
Is this a recommendation to cloak a site from browsers?
No. It is a testing guide. Serving materially different content to testers and to users, or using UA sniffing as a substitute for responsive design, is usually a maintenance problem, not a strategy this article endorses.
Disclaimer
This article is general information about user-agent testing on Android, using official Dev Browser features and the MDN description of the User-Agent header. Browser behaviour, site code and app screens can change. Confirm what you see on the page under test, and consult the current product guide for the labelled controls in the version you have installed.
References
- MDN Web Docs, User-Agent header: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/User-Agent.
- My Advisers, Dev Browser product guide (desktop and tablet user agents, width presets, forced layout width, live viewport readout): https://myadvisers.in/dev-browser/.
Comments
Post a Comment