Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Viewport meta tag for iOS devices

Does stating

<meta name="viewport" content="width=device-width" />

have the same effect as stating

<meta name="viewport" content="width=768" />

for the ipad?

like image 235
pingu Avatar asked Oct 25 '11 16:10

pingu


People also ask

What is the viewport meta tag?

The viewport meta tag tells the browser that the width of the screen should be considered the "Full Width" of the page. Meaning no matter the width of the device you are on, whether on desktop or mobile. the website will follow the width of the device the user is on.

Where do I put a viewport meta tag?

Throw the viewport meta tag into your <head> , plus the @viewport rule into your CSS when you're building flexible layouts and you're good to go.

What is meta in iPhone?

Nearly every photo you take on your iPhone has a batch of hidden information stored within: metadata. This metadata, known more specifically as EXIF data for images, contains descriptive information that makes each image unique. That includes the creation date, camera information and settings and your location.

How do you set a viewport?

Setting The ViewportThe width=device-width part sets the width of the page to follow the screen-width of the device (which will vary depending on the device). The initial-scale=1.0 part sets the initial zoom level when the page is first loaded by the browser.


1 Answers

It depends indeed on the orientation of the device: setting a specific pixel value will cause your layout to be scaled up with a factor of 1.333 to fit inside the 1024px device width when in landscape mode.

Setting width=device-width on the other hand will not scale anything up, but change the viewport width, for which you then can craft an optimized layout using media queries. Or that is at least the theory: the iPad somehow interprets width=device-width as 768px even in landscape mode. In order to get the real device width, you have to add initial-scale=1.

Hence, I disagree with James' suggestion. Just go for:

<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

and deal with size differences using liquid / responsive layout techniques.

like image 100
andreasbovens Avatar answered Sep 28 '22 16:09

andreasbovens