Summary -

In this topic, we described about the <meta> tag along with detailed example.

<meta> tag represents HTML document metadata. Metadata is nothing but the information about the HTML document. In another words, Metadata is data about data.

Metadata is everything except the information covered in title, style, link, base, script elements. Metadata will not be displayed on the page. Metadata will be machine understandable. Metadata can be used by browsers to get how to display content or reloading page.

Metadata can be used by search engines to crawl the web page by using keywords. Metadata mostly used to specify keywords, description of the page, author, last modified etc,. <meta> tag supports by all kind of browsers. <meta> tag has no ending tag in HTML. All the attributes are optional.

Rules -

  1. At a time one of name, http-equiv, or charset should be used in any meta element.
  2. Meta tags always pass as name or value.
  3. <meta> tag always coded in <head> tag.

Optional Attributes -

AttributeDescriptionValues
nameName of metadata specified. Text.
author: The author’s name of the page.
description: description of the page amd also often used in search engine results.
keywords: Comma-separated keywords relevant to the document content and used by search engines.
viewport: instructions used to pass to mobile devices.
robots: Instructs page crawlers from search engines what to do in regard to indexing of the page.
http-equivProvides an HTTP header(server side instruction) for the information/value of the content attribute content-type: Character encoding declaration.
default-style: The preferred stylesheet.
refresh: A timed refresh, in seconds, or redirect. Evil.
contentThe value of the element. Text.
charsetThe character encoding of the HTML page. UTF-8 is advised.

Example -

<!DOCTYPE html>
<html lang="en">
    <head>
        <title>Base tag example</title>
        <meta name="description" content="HTML meta tags">
        <meta name="keywords" content="Html meta tags">
        <meta name="author" content="">
    </head>
    <body>
       <!-- Content of the HTML document -->
       <p> HTML page with Description, Keyword and author meta tags</p>
    </body>
</html>