HTML Meta tags and Meta data.

HTML Meta tags and Meta data.

<meta>

The <meta> tag is used to provide metadata or information about the HTML document. This information is not displayed on the web page itself, but rather is used by browsers, search engines, and other web services.

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

When you create a new HTML file in VSCode using the HTML boilerplate, it generates a basic HTML template that includes a <head> section. Within the <head> section, you may notice several <meta> tags with various attributes.

By providing metadata about your HTML document, you can improve the search engine optimization (SEO) of your website and enhance its accessibility for users.

Here are some <meta> tag attributes and their purposes:

  1. charset: Specifies the character encoding used in the document, typically UTF-8.

  2. name="viewport": Specifies the viewport settings for mobile devices, such as the width of the viewport and the initial zoom level.

  3. name="description": Provides a brief description of the page's content, which can be used by search engines to display a summary of the page in search results.

  4. name="keywords": Specifies a comma-separated list of keywords relevant to the page's content.

  5. name="author": Specifies the author of the page.

  6. http-equiv="refresh": Redirects or refreshes the page after a specified number of seconds.

Now let's understand these meta tags and their attributes and what they are doing with browsers......

  •   <meta charset="UTF-8">
    

    UTF-8 is a variable-length character encoding that can represent any character in the Unicode standard, which includes most of the world's writing systems. By using UTF-8, web developers can ensure that their web pages can display text in any language and can handle special characters and symbols correctly.

    This tells the web browser that the document is encoded using UTF-8, which enables the browser to correctly interpret and display the document's content.

    So, UTF-8 is standard to write or understand character and text??

    UTF-8 is a widely accepted standard for encoding and representing text characters in computing. It is a variable-length encoding that can represent any character in the Unicode character set, which includes characters from most of the world's writing systems.

    UTF-8 has become the de facto standard for text encoding on the web, and it is supported by most modern web browsers, programming languages, and operating systems. It is also commonly used in data exchange formats such as JSON and XML.

    UTF-8 provides a way for computers to store, transmit, and display text in a way that is compatible with different languages and scripts. This makes it possible to create web pages, applications, and other digital content that can be accessed and understood by people around the world, regardless of their language or writing system.

    Unicode what is it-

    Unicode is a standard character encoding system that assigns unique numbers to each character in most of the world's writing systems, including scripts for languages such as Arabic, Chinese, Cyrillic, Hebrew, and many others. The Unicode standard includes over 143,000 characters, covering a wide range of languages and scripts, as well as symbols, emojis, and other special characters.

  •   <meta name="description" content="This is a brief description of the content of the webpage.">
    

    The name attribute is set to "description", which tells the browser that the <meta> tag provides a description of the webpage's content. The content attribute provides the actual content of the description, which is a brief summary of what the webpage is about.

    The description meta tag is often used by search engines and other services that index and display web content, as it provides a concise summary of what a webpage is about. The content of the description tag may be used in search engine results pages (SERPs) as the snippet of text that appears below the page title and URL, helping users to determine whether the page is relevant to their search query.

  •   <meta name="keywords" content="blog, frontend, html, Javascript">
    

    The <meta name="keywords" content="keyword1, keyword2, keyword3"> tag is used to provide a list of keywords that are relevant to the content of a webpage. This tag is an example of a meta tag that was used more frequently in the past, but now has a reduced importance for SEO.

    • name="keywords": This specifies that the meta tag is related to keywords.

      • content="keyword1, keyword2, keyword3": This provides a comma-separated list of keywords that are relevant to the content of the webpage.
<meta http-equiv="X-UA-Compatible" content="IE=edge">

The <meta http-equiv="X-UA-Compatible" content="IE-edge"> tag is used to specify the compatibility mode for Internet Explorer (IE) browser rendering. It tells the browser to use the latest available rendering engine and document mode, rather than an older version of IE's rendering engine.

In older versions of IE, Microsoft introduced different rendering modes that were used to render web pages in order to maintain backward compatibility with legacy web pages. The X-UA-Compatible meta tag allows web developers to specify which rendering mode should be used for their web pages, even if the page was designed for an older version of IE......

By setting the value to "IE-edge", the browser is instructed to use the latest available rendering engine, rather than a legacy rendering engine. This can help to ensure that the web page is rendered consistently across different versions of IE, and can also improve compatibility with other modern browsers.

Role of http-equiv-

The http-equiv attribute specifies the name of the HTTP header to be emulated, and its value is the content of that header. When a web browser or server encounters a <meta> element with an http-equiv attribute, it will treat the content of the element as if it were an HTTP header with the specified name and value.

For example, in the case of <meta http-equiv="X-UA-Compatible" content="IE-edge">, the http-equiv attribute is set to "X-UA-Compatible", which emulates the corresponding HTTP response header. The content of the <meta> element, "IE-edge", is the value of the header.

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

The <meta name="viewport" content="width=device-width, initial-scale=1.0"> tag is used to control the width and scaling of the viewport on mobile devices. It's important for creating a responsive design that displays properly on various screen sizes.

image from-exoclicks...

Let's break down each part of the content attribute:

  • width=device-width: This sets the width of the viewport to the width of the device. This is important for making sure that the content fits on the screen without being too large or too small.

  • initial-scale=1.0: This sets the initial zoom level of the page to 1.0, which means that the page is displayed at its actual size without any zooming or scaling. This ensures that the content appears in the correct size on different devices.