A quoi sert le code ( <meta name="viewport" content="width=device-width, initial-scale=1.0"> placé entre des deux head de HTML ? )

Asked  Nov 19, 07:24 pm 23 Views Add Your Answer
Asked  Nov 19, 07:24 pm
0 Dislikes

1 Answers

Edited  Nov 20, 12:16 pm

What is The Viewport?

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.

Then, when we started surfing the internet using tablets and mobile phones, fixed size web pages were too large to fit the viewport. To fix this, browsers on those devices scaled down the entire web page to fit the screen.

This was not perfect!! But a quick fix.

Setting The 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 all your web pages:

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

This gives the browser instructions on how to control the page's dimensions and scaling.

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.

If you want to know more about this topic go to w3schools

0 Likes 0 Dislikes
Google login
SignUp with Email