Home > Article > Web Front-end > How to Detect Mobile Browsers: iOS and Android?
Detecting Mobile Browsers: iOS and Android
Q: How can I determine if a mobile browser is in use on iOS or Android?
A: To distinguish handheld browsers from standard desktop browsers, consider employing CSS media queries.
The following media query checks for the presence of either a "pointer:none" or "pointer:coarse" attribute, which is often associated with handheld devices:
@media (pointer:none), (pointer:coarse) { }
This allows you to apply specific styling or behavior specifically to handheld devices.
Here's a previous attempt that didn't yield desired results:
width: 600px; @media handheld { width: 300px; }
However, the "handheld" media query is less reliable for identifying mobile devices and should be used with caution.
The above is the detailed content of How to Detect Mobile Browsers: iOS and Android?. For more information, please follow other related articles on the PHP Chinese website!