What is the use of Meta Tag in html

Viewed 33

Why do we use meta tag in html and what is the purpose of the given code.

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

According to W3Schools -

The <meta> tag defines metadata about an HTML document. Metadata is data (information) about data. These tags are typically used to specify character set, page description, keywords, author of the document, and viewport settings.

The line you provided deals with the viewport settings, i.e, the users visible area of the webpage. According to W3Schools -

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.

The above code:

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

Tells the browser what to do with the content on the website when viewed on a mobile device. Here is an example without and with this code:

Without the meta tag

enter image description here

With the meta tag

enter image description here

Hopefully that should answer your question.

Related