Distinguishing Mobile from Desktop UA
User-Agent Guide
You refer to the User-Agent when splitting device types in responsive server handling or statistics. The clearest signal is the Mobile token included in the string.
Key Signals
- Desktop: platform tokens like
Windows NT,Macintosh,X11; Linux - Mobile: the
Mobiletoken +AndroidoriPhone - Tablet:
iPad, orAndroidwithoutMobile
Common Pitfalls
Safari on iPadOS requests the desktop site by default, so it sends a UA almost identical to macOS. As a result the iPad token may be absent, and by the UA alone it's easy to mistake an iPad for a desktop.
A Better Approach
Actual capabilities such as screen size and touch support are more accurately detected with JavaScript or CSS media queries than with the UA. It's recommended to use the UA only for a first-pass estimate on the server side and handle fine-grained branching on the client.
In the end, device detection is most robust when it combines the UA (server) with feature detection (client).