- The viewport is the user's visible area of a web page.π©βπ»
- The viewport varies with the device, and will be smaller on a mobile phone than on a computer screen.
- Before tablets and mobile phones, web pages were designed only for computer screens, and it was common for web pages to have a static design and a fixed size
Viewport
HTML5 introduced a method to let web designers take control over the viewport, through the <meta>
tag.
You should include the following <meta>
viewport element in the <head>
section of all your web pages:
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
- The 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
Top comments (0)