How Safari's Per-Domain Desktop and Mobile Toggle Works

Safari’s Website Settings include a powerful feature that lets users permanently choose between the mobile and desktop versions of a site on a per-domain basis. This article provides a straightforward explanation of the technical mechanisms behind the "Request Desktop Website" and "Request Mobile Website" toggles, detailing how Safari alters its identity, adjusts screen rendering, and remembers your preferences for specific domains.

The User-Agent String Modification

The primary way a website knows what kind of device you are using is through the User-Agent (UA) string. This is a line of text your browser sends to the website's server every time you load a page.

  • Default Mobile Behavior (iOS): By default, an iPhone sends a UA string identifying itself as a mobile device running iOS. The server reads this and sends back the mobile version of the website.
  • Default Desktop Behavior (iPadOS): Modern iPads send a macOS desktop UA string by default because their screens are large enough to handle desktop sites.

When you toggle Request Desktop Website on an iPhone, Safari stops sending the iOS UA string for that domain. Instead, it spoofs its identity by sending the exact same UA string used by Safari on a Mac running macOS. Conversely, when you toggle Request Mobile Website on an iPad, Safari swaps its macOS UA string back to a mobile iOS string.

Viewport and CSS Media Query Adjustments

Modern websites often do not rely solely on the User-Agent string; they use Responsive Web Design (RWD). RWD relies on CSS media queries to detect the pixel width of your screen (the viewport) and rearranges the layout dynamically.

If Safari only changed the User-Agent string on an iPhone, a responsive website would still see a narrow screen width (e.g., 390 pixels wide) and display the mobile layout anyway. To bypass this, the toggle also changes the virtual viewport:

  • When requesting the desktop site: Safari creates a virtual viewport that mimics a standard desktop monitor (typically around 980 pixels wide or more) and scales the resulting webpage down to fit your physical screen. This forces the website's CSS to trigger its desktop layout rules.
  • When requesting the mobile site: Safari restricts the viewport width to match standard mobile dimensions, forcing the website's CSS to collapse menus and stack elements vertically for mobile viewing.

Feature Detection and Input Translation

Some complex web applications use JavaScript to detect specific hardware features, such as multi-touch support or mouse pointers, to decide which version of a site to load.

When you force a desktop site on a touch device via Safari's toggle, WebKit (Safari’s rendering engine) disables certain mobile-specific JavaScript APIs for that tab and maps your finger taps to simulate traditional mouse clicks and hover states. This prevents the website's scripts from realizing you are on a mobile device and redirecting you back to a mobile URL (like m.example.com).

Per-Domain Persistence in Website Settings

While you can request a desktop or mobile site temporarily for a single session via the browser's share sheet or reload button, changing it inside Website Settings makes the change permanent for that specific web address.

When you open the "aA" menu (or the Page Settings icon) in the address bar, select Website Settings, and flip the toggle, Safari writes a rule into a local SQLite database stored on your device.

  1. Domain Extraction: Safari strips away the specific page path and isolates the root domain (e.g., changing https://www.example.com/news/today to just example.com).
  2. Database Entry: It saves a boolean value (True/False) associated with that domain name under its per-site preferences list.
  3. Pre-Request Check: Every time you navigate to a URL, Safari checks this local database before sending the network request. If the domain matches an entry in the database, Safari automatically applies the spoofed User-Agent string and modified viewport dimensions before the server even knows you are visiting.

You can view and manage all the domains you have configured this way by going to the main Settings app on iOS/iPadOS, selecting Safari, and tapping on Request Desktop Website under the Settings for Websites section. On a Mac, this is managed via Safari Settings > Websites > Request Desktop Website.