How large is the usable area in iPad Safari
If you want to know screen aspects you could check iPad Peek and load a site like NYTIMES. this gives the exact usable screen dimensions for the iPad.
Hope this helps
So - on my ipad (ipad1, ios 5.1.1) I got slightly different numbers than above. Probably because the tab and bookmarks bars are showing.
My values:
portrait : 768 x 900 landscape : 1024 x 644
So I wrote a javascript bookmarklet to get a proof positive result. You can email this to yourself, goto "about:blank" in safari, create a bookmark, edit it and cut/paste this code out of email :)
When you get the bookmarklet running re-size the div until it matches the window and tada..
<pre><code>
javascript:( function(){
"use strict";
var bmIdVal = "ios_screen_res_test_bookmarklet";
var bmDivSize = {
w : 320,
h : 240
};
var vpMeta1 = document.createElement('meta');
vpMeta1.setAttribute("name","viewport");
vpMeta1.setAttribute("content",'initial-scale=1.0, user-scalable=no');
document.head.appendChild(vpMeta1);
function updateStatus(){
statusDiv.innerHTML = "div is " + bmDivSize.w + ',' + bmDivSize.h +
" doc body says: " + document.body.clientWidth + "," +
document.body.clientHeight;
}
function resizeBmDiv(wPx,hPx){
bmDivSize.w += wPx;
bmDivSize.h += hPx;
bmDiv.style.width=bmDivSize.w + "px";
bmDiv.style.height=bmDivSize.h + "px";
updateStatus();
}
var prevBmDiv = document.getElementById(bmIdVal);
if( prevBmDiv != null){
document.body.removeChild(prevBmDiv);
}
var bmDiv = document.createElement("div");
bmDiv.setAttribute("id",bmIdVal);
bmDiv.style.cssText =
"position:absolute;left:0px;top:0px;background-color: #0066FF";
bmDiv.style.width=bmDivSize.w + "px";
bmDiv.style.height=bmDivSize.h + "px";
var sizerB_w1 = document.createElement("button");
sizerB_w1.style.cssText = "width:64px;height:64px";
sizerB_w1.innerHTML="w+1";
sizerB_w1.onclick = function(evt){
resizeBmDiv(1,0);
};
var sizerB_w100 = document.createElement("button");
sizerB_w100.style.cssText = "width:64px;height:64px";
sizerB_w100.innerHTML="w+100";
sizerB_w100.onclick = function(evt){
resizeBmDiv(100,0);
};
var sizerB_h1 = document.createElement("button");
sizerB_h1.style.cssText = "width:64px;height:64px";
sizerB_h1.innerHTML="h+1";
sizerB_h1.onclick = function(evt){
resizeBmDiv(0,1);
};
var sizerB_h100 = document.createElement("button");
sizerB_h100.style.cssText = "width:64px;height:64px";
sizerB_h100.innerHTML="h+100";
sizerB_h100.onclick = function(evt){
resizeBmDiv(0,100);
};
var sizerDiv = document.createElement('div');
sizerDiv.appendChild(sizerB_w1);
sizerDiv.appendChild(sizerB_w100);
sizerDiv.appendChild(sizerB_h1);
sizerDiv.appendChild(sizerB_h100);
var sizerB_wm1 = document.createElement("button");
sizerB_wm1.style.cssText = "width:64px;height:64px";
sizerB_wm1.innerHTML="w-1";
sizerB_wm1.onclick = function(evt){
resizeBmDiv(-1,0);
};
var sizerB_wm100 = document.createElement("button");
sizerB_wm100.style.cssText = "width:64px;height:64px";
sizerB_wm100.innerHTML="w-100";
sizerB_wm100.onclick = function(evt){
resizeBmDiv(-100,0);
};
var sizerB_hm1 = document.createElement("button");
sizerB_hm1.style.cssText = "width:64px;height:64px";
sizerB_hm1.innerHTML="h-1";
sizerB_hm1.onclick = function(evt){
resizeBmDiv(0,-1);
};
var sizerB_hm100 = document.createElement("button");
sizerB_hm100.style.cssText = "width:64px;height:64px";
sizerB_hm100.innerHTML="h-100";
sizerB_hm100.onclick = function(evt){
resizeBmDiv(0,-100);
};
var sizerMDiv = document.createElement('div');
sizerMDiv.appendChild(sizerB_wm1);
sizerMDiv.appendChild(sizerB_wm100);
sizerMDiv.appendChild(sizerB_hm1);
sizerMDiv.appendChild(sizerB_hm100);
var statusDiv = document.createElement('div');
statusDiv.style.cssText = "color:white;";
bmDiv.appendChild(statusDiv);
bmDiv.appendChild(sizerDiv);
bmDiv.appendChild(sizerMDiv);
document.body.appendChild(bmDiv);
updateStatus();
})();
</code></pre>
You should just follow TN2262 and write dimension-invariant code.
In case you need a logical pixel size, document.body.client[Width|Height]
is always 980×1208.
In terms of absolute pixels you can use, the navigation bar of Mobile Safari takes up roughly 78px, so in portrait orientation it is 768×946, and in landscape it is 1024×690.
There can be a keyboard (308px in height in portrait, 397px in landscape) as well.
Update: The above absolute numbers are correct only for iOS 4.x or before. In iOS 5.x Apple introduced the tab bar which increases the height of navigation bar + status bar to 96px. Actually, even before iOS 5.x, the presence of the bookmark bar can affect the viewport as well.