Here’s the inevitable compatibility table that goes with my viewport research. It treats the viewports themselves as well as some related items.
position: fixed was moved to the CSS test pages.
This is the mobile table. See also the desktop table.
See A tale of two viewports for a further explanation of these terms.
width: 20% are calculated relative to this viewport. Is usually quite a bit wider than the visual viewport.This table looks into the properties that are necessary to read out useful information about the two viewports. As you can see, a few browsers make a mess of them, but most suport them well.
UC behaviour is undescribable. Very, very bad. Layout viewport changes with zoom, meta viewport not supported meaningfully, most of the other measurements don’t make any kind of sense.
| Selector | iOS | Android | Chrome | Opera | Black |
Nokia | UC | Net |
Dol |
One | Tizen | IE | Firefox | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5 | 6 | 2 | 3 | 4 | 18 | 25 | Mini | Mob 12 | Mob 14 | 6 | 7 | PB | 10 | Xpress | Mee |
Anna | Belle | 9 | 10 | |||||||
|
screen.width and screen.height
Screen resolution in device pixels (and not dips). Should change when the orientation of the device is changed. |
dips no-or | 800 | Yes | Avail | dips | Avail dips | Avail | dips no-or | Yes | Incor |
Bug |
Yes | Bug |
Yes | no-or | Yes | ||||||||||
|
||||||||||||||||||||||||||
|
window.innerWidth and window.innerHeight
Dimensions of the visual viewport in CSS pixels. |
Yes | Layout | Yes | Yes | Bug |
Yes | Yes | Not sure | Yes | Layout | Yes | Layout | Yes | Layout | ||||||||||||
|
||||||||||||||||||||||||||
| Selector | iOS | Android | Chrome | Opera | Black |
Nokia | UC | Net |
Dol |
One | Tizen | IE | Firefox | |||||||||||||
| 5 | 6 | 2 | 3 | 4 | 18 | 25 | Mini | Mob 12 | Mob 14 | 6 | 7 | PB | 10 | Xpress | Mee |
Anna | Belle | 9 | 10 | |||||||
|
documentElement. clientWidth and documentElement. clientHeight
Dimensions of the layout viewport in CSS pixels. |
Yes | Yes | Yes | Bug |
Yes | Yes | Not sure | Yes | Bug |
Yes | Yes | |||||||||||||||
|
||||||||||||||||||||||||||
|
Calculate zoom level
Zoom level can only be calculated if the previous two entries have a Yes. |
Yes | No | Yes | Yes | No | Yes | Yes | No | Yes | No | Yes | No | Yes | No | ||||||||||||
zoom level = document.documentElement.clientWidth / window.innerWidth |
||||||||||||||||||||||||||
|
documentElement. offsetWidth and documentElement. offsetHeight
Dimensions of the |
Yes | Yes | Yes | Bug |
Yes | Yes | Yes | Yes | Yes | Layout | Yes | |||||||||||||||
|
||||||||||||||||||||||||||
|
pageXOffset and pageYOffset
Scrolling offset of the page in CSS pixels. |
Yes | Yes | Yes | 0 | Yes | Yes | 0 | Yes | Bug |
Yes | Yes | |||||||||||||||
|
devicePixelRatio
device pixels divided by dips |
Yes | Yes | Yes | 1 | Yes | Yes | No | Bug |
Yes | Bug |
Yes | 1 | Yes | 1 | No | 1 | ||||||||||
|
||||||||||||||||||||||||||
| Selector | iOS | Android | Chrome | Opera | Black |
Nokia | UC | Net |
Dol |
One | Tizen | IE | Firefox | |||||||||||||
| 5 | 6 | 2 | 3 | 4 | 18 | 25 | Mini | Mob 12 | Mob 14 | 6 | 7 | PB | 10 | Xpress | Mee |
Anna | Belle | 9 | 10 | |||||||
| Selector | iOS | Android | Chrome | Opera | Black |
Nokia | UC | Net |
Dol |
One | Tizen | IE | Firefox | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5 | 6 | 2 | 3 | 4 | 18 | 25 | Mini | Mob 12 | Mob 14 | 6 | 7 | PB | 10 | Xpress | Mee |
Anna | Belle | 9 | 10 | |||||||
|
clientX/Y
In CSS pixels, relative to the visual viewport |
Yes | Yes | Yes | page | Yes | Yes | Bug |
Yes | Yes | Yes | Bug |
Yes | ||||||||||||||
clientX/Y = pageX/Y - window.pageX/YOffset
|
||||||||||||||||||||||||||
|
pageX/Y
In CSS pixels, relative to the layout viewport |
Yes | Yes | Yes | Yes | Yes | Bug |
Yes | Yes | Yes | |||||||||||||||||
|
pageX/Y uses the same coordinate system as |
||||||||||||||||||||||||||
|
screenX/Y
In device pixels, relative to the visual viewport |
Incor |
client | Yes | 0 | page | client | 0 | page | client+ | Yes | Bug |
Yes | Bug |
client | page+ | Bug |
client | |||||||||
screenX/Y = clientX/Y * devicePixelRatio * zoom zoom = documentElement.clientWidth / window.innerWidth
|
||||||||||||||||||||||||||
| Selector | iOS | Android | Chrome | Opera | Black |
Nokia | UC | Net |
Dol |
One | Tizen | IE | Firefox | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 5 | 6 | 2 | 3 | 4 | 18 | 25 | Mini | Mob 12 | Mob 14 | 6 | 7 | PB | 10 | Xpress | Mee |
Anna | Belle | 9 | 10 | |||||||
|
Basics
Sets the dimensions of the layout viewport. |
Yes | Yes | Yes | Al |
Yes | Yes | Hard |
Yes | No | Yes | Yes | |||||||||||||||
<meta name="viewport" content="width = 380"> <meta name="viewport" content="width = device-width"> Should narrow the layout viewport to the indicated width. The
| ||||||||||||||||||||||||||
|
Change immediately
Change the tag directly after it’s been written into the page Test page |
Yes | Yes | Yes | Yes | Yes | Yes | No | Yes | No | Yes | No | |||||||||||||||
<meta id="testViewport" name="viewport" content="width = 380">
<script>
var mvp = document.getElementById('testViewport');
mvp.setAttribute('content','width=480');
</script>
|
||||||||||||||||||||||||||
| Selector | iOS | Android | Chrome | Opera | Black |
Nokia | UC | Net |
Dol |
One | Tizen | IE | Firefox | |||||||||||||
| 5 | 6 | 2 | 3 | 4 | 18 | 25 | Mini | Mob 12 | Mob 14 | 6 | 7 | PB | 10 | Xpress | Mee |
Anna | Belle | 9 | 10 | |||||||
|
Change later
Change the tag once the page has been loaded Test page |
Yes | Yes | Yes | No | Yes | No | No | Yes | No | Yes | No | Yes | No | |||||||||||||
<meta id="testViewport" name="viewport" content="width = 380">
<script>
window.onload = function () {
var mvp = document.getElementById('testViewport');
mvp.setAttribute('content','width=580');
}
</script>
|
||||||||||||||||||||||||||
|
Remove
Remove the tag entirely Test page |
No | No | No | No | Yes | No | No | No | No | No | ||||||||||||||||
<meta id="testViewport" name="viewport" content="width = 380">
<script>
window.onload = function () {
var mvp = document.getElementById('testViewport');
mvp.removeAttribute('content');
}
</script>
I expect the page becomes as wide as the default layout viewport; i.e. behaves the same as if no meta viewport were set.
|
||||||||||||||||||||||||||
Mobile browser test array 1.0.5; March 2013
General note on One and UC: the browsers I test are not particularly representative for the actual browsers that are used in the wild. Though some may be default browsers on Asian Android devices, most of them get their market share from being pre-installed on feature phones or game consoles.I’m working on getting more representative test devices.
Browsers by WebKit version: