Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the effect of setting meta viewport tag with `height=device-height`?

I understand that the default behavior of iOS regarding device-width might be to try to render websites using a viewport width of 980px, and setting width=device-width might be useful (particularly if you are developping a Cordova/mobileApp/SPA.

However I'm not sure to understand when should we set height=device-height. Does adding this line have any effect? Isn't it the default behavior to use the device height as the viewport height?

I have a mobile app, that is available both as a mobile website and a cordova native app. There are 2 separate index.html pages with different settings (legacy):

// Mobile website has:

// Cordova has:

I'd like to know the risks I encounter of using the same content value for both cases (which seems like it's mostly arround device-height)

I didn't find the online documentation to be really helpful on that subject. Any idea?

like image 334
Sebastien Lorber Avatar asked Jun 28 '16 14:06

Sebastien Lorber


People also ask

What is the purpose of the meta viewport tag?

Setting the viewport meta tag lets you control the width and scaling of the viewport so that it's sized correctly on all devices.

Which tag is used to change the viewport according to the display size?

This article describes how to use the "viewport" <meta> tag to control the viewport's size and shape.

How do you change the height of a viewport in HTML?

A simple way to solve this is to use the viewport percentage unit vh instead of %. One vh is defined as being equal to 1% of a viewport's height. As such, if you want to specify that something is 100% of the latter, use " height: 100vh ". Or if you want to make it half the height of the viewport, say " height: 50vh ".

What is viewport width and height?

In an SVG document, the viewport is the visible area of the SVG image. You can set any height and width on an SVG, but the whole image might not be visible. The area that is visible is called the viewport. The size of the viewport can be defined using the width and height attributes of the <svg> element.


1 Answers

The online documentation you linked does point to the specs:

https://drafts.csswg.org/css-device-adapt/#width-and-height-properties

device-width and device-height translate to 100vw and 100vh respectively

like image 196
Ernesto Ramírez Romero Avatar answered Nov 02 '22 23:11

Ernesto Ramírez Romero