meta

The <meta> HTML element is a metadata content element that contain information about presentation and behavior the page. This element is used inside <head> HTML element. The <meta> HTML element represents information that can not be represented by other metadata content elements like: <base>, <link>, <script>, <style>, <title>.

One of the following attributes must be specified for the HTML <meta> element to be valid:

  • name
  • http-equiv
  • charset

If the name or http-equiv attribute is specified, then the content attribute must also be present. The value of the content attribute depends on the value of the http-equiv and name attribute.

The charset attribute

<meta charset="utf-8" />

The charstet attribute specifies the character encoding used of the page. Preferred value for this attribute is utf-8. This charset declaration must be set in the <head> element within the 1024 first bytes of page because some browsers look only these first bytes before choosing a character set for the page. If this declaration is omitted or declared to late in the document the browser could guess wrongly and decided that the page is encoded in UTF-7 that may lead to harm the page (UTF-7 fallback cross-scripting technique).

The charset attribute can be overridden by using the lang attribute on any element.

The http-equiv attribute

The http-equiv attribute defines pragma directives that can alter servers and user-agents behavior. The value of the pragma is defined as the value of the content attribute. The possible value of http-equiv attribute:

  • default-style – the attribute specifies the preferred style sheet to be used on the page. The value of the content attribute must contain the value of the title attribute of a <link> element or a <style> element.
    <meta http-equiv="default-style" content="the document's preferred stylesheet" />
  • refresh – the attribute specifies the time until the page should be reloded or should be redirected to another page. The value of the content attribute is time in seconds: content="200"  – that means that the page will be reloaded after 200 seconds. The another possibility of value of  this attribute is: conent="200; url=page2.html". That means  that the page will be redirected to page2.html after 200 seconds.
    <meta http-equiv="refresh" content="200" />
    <meta http-equiv="refresh" content="200; url=page2.html" />
  • Common example usage of the http-equiv attribute is defines directive for Internet Explorer browser:
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    This directive tells IE to use the latest, or edge version of the IE rendering environment.

The name attribute

The name attribute defines the name of document-level metadata. The possible values for name attribute:

  • application-name – specifies the name of the Web application that the page represents.
    If the page is not the web application this attribute must not be used.
  • author – the name of the author
    <meta name="author" content="Big Fat Cat" />
  • description – contains a short summary of the content of the page
    <meta name="description" content="Funny page about funny cats" />
  • generator – contain the identifier to the software that generated the page
    <meta name="generator" content="FrontPage 4.0" />
  • keywords – contains relevant words associated with page
    <meta name="keywords" content="cat, funny cats" />
  • viewport – controls a viewport
    <meta name="viewport" content="width=device-width, initial-scale=1" />

Resources:

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.