World Wide Web Consortium (W3C)

Elements/meta

The element represents various kinds of metadata that cannot be expressed using the title, base, link, style, and script elements.

Point

  • If either name or http-equiv is specified, then the content attribute must also be specified. Otherwise, it must be omitted.

HTML Attributes

  • name = string
    Sets document metadata.
    • application-name
      Giving the name of the Web application that the page represents.
    • author
      Giving the name of one of the page’s authors.
    • description
      Describes the page. [Exapmle A]
    • generator
      Identifies one of the software packages used to generate the document.
    • keywords
      Giving the keyword relevant to the page. [Exapmle A]

    Other metadata names may be registered in the WHATWG Wiki MetaExtensions page.

    • http-equiv = string
      When the http-equiv attribute is specified on a meta element, the element is a pragma directive.
      • content-language
        Sets the pragma-set default language.
      • content-type
        Alternative form of setting the charset attribute
      • default-style
        Sets the name of the default alternative style sheet set.
      • refresh
        Acts as timed redirect. [Exapmle B]
      • content = string
        Gives the value of the document metadata or pragma directive when the element is used for those purposes.

      Example

      Example A

         

      Example B

      A news organization’s front page could include the following markup in the page’s head element, to ensure that the page automatically reloads from the server every five minutes:

      HTML Reference

      The HTML5 specification defines the element in 4.2.5 The meta element.

      Источник

      HTML Tag

      The tag defines metadata about an HTML document. Metadata is data (information) about data.

      tags always go inside the element, and are typically used to specify character set, page description, keywords, author of the document, and viewport settings.

      Metadata will not be displayed on the page, but is machine parsable.

      Metadata is used by browsers (how to display content or reload page), search engines (keywords), and other web services.

      There is a method to let web designers take control over the viewport (the user’s visible area of a web page), through the tag (See «Setting The Viewport» example below).

      Browser Support

      Attributes

      Attribute Value Description
      charset character_set Specifies the character encoding for the HTML document
      content text Specifies the value associated with the http-equiv or name attribute
      http-equiv content-security-policy
      content-type
      default-style
      refresh
      Provides an HTTP header for the information/value of the content attribute
      name application-name
      author
      description
      generator
      keywords
      viewport
      Specifies a name for the metadata

      Global Attributes

      More Examples

      Define keywords for search engines:

      Источник

      : The metadata element

      The HTML element represents metadata that cannot be represented by other HTML meta-related elements, like , , , or .

      • , : a element. If the http-equiv is not an encoding declaration, it can also be inside a element, itself inside a element.
      • : any element that accepts metadata content.
      • : any element that accepts metadata content or flow content.

      The type of metadata provided by the element can be one of the following:

      • If the name attribute is set, the element provides document-level metadata, applying to the whole page.
      • If the http-equiv attribute is set, the element is a pragma directive, providing information equivalent to what can be given by a similarly-named HTTP header.
      • If the charset attribute is set, the element is a charset declaration, giving the character encoding in which the document is encoded.
      • If the itemprop attribute is set, the element provides user-defined metadata.

      Attributes

      This element includes the global attributes.

      Note: the attribute name has a specific meaning for the element, and the itemprop attribute must not be set on the same element that has any existing name , http-equiv or charset attributes.

      This attribute declares the document’s character encoding. If the attribute is present, its value must be an ASCII case-insensitive match for the string «utf-8» , because UTF-8 is the only valid encoding for HTML5 documents. elements which declare a character encoding must be located entirely within the first 1024 bytes of the document.

      This attribute contains the value for the http-equiv or name attribute, depending on which is used.

      Defines a pragma directive. The attribute is named http-equiv(alent) because all the allowed values are names of particular HTTP headers:

      • content-security-policy Allows page authors to define a content policy for the current page. Content policies mostly specify allowed server origins and script endpoints which help guard against cross-site scripting attacks.
      • content-type Declares the MIME type and the document’s character encoding. The content attribute must have the value «text/html; charset=utf-8» if specified. This is equivalent to a element with the charset attribute specified and carries the same restriction on placement within the document. Note: Can only be used in documents served with a text/html — not in documents served with an XML MIME type.
      • default-style Sets the name of the default CSS style sheet set.
      • x-ua-compatible If specified, the content attribute must have the value «IE=edge» . User agents are required to ignore this pragma.
      • refresh This instruction specifies:
        • The number of seconds until the page should be reloaded — only if the content attribute contains a non-negative integer.
        • The number of seconds until the page should redirect to another — only if the content attribute contains a non-negative integer followed by the string ‘ ;url= ‘, and a valid URL.

        Pages set with a refresh value run the risk of having the time interval being too short. People navigating with the aid of assistive technology such as a screen reader may be unable to read through and understand the page’s content before being automatically redirected. The abrupt, unannounced updating of the page content may also be disorienting for people experiencing low vision conditions.

        The name and content attributes can be used together to provide document metadata in terms of name-value pairs, with the name attribute giving the metadata name, and the content attribute giving the value.

        See standard metadata names for details about the set of standard metadata names defined in the HTML specification.

        Examples

        meta charset="utf-8" /> meta http-equiv="refresh" content="3;url=https://www.mozilla.org" /> 

        Specifications

        Browser compatibility

        BCD tables only load in the browser

        See also

        Found a content problem with this page?

        This page was last modified on Jul 18, 2023 by MDN contributors.

        Your blueprint for a better internet.

        MDN

        Support

        Our communities

        Developers

        Visit Mozilla Corporation’s not-for-profit parent, the Mozilla Foundation.
        Portions of this content are ©1998– 2023 by individual mozilla.org contributors. Content available under a Creative Commons license.

        Источник

        META (proposed)

        The META element can be used within the HEAD element to embed document metainformation not defined by other HTML elements. Such information can be extracted by servers/clients for use in identifying, indexing, and cataloging specialized document metainformation.

        Although it is generally preferable to use named elements which have well-defined semantics for each type of metainformation (e.g. TITLE), this element is provided for situations where strict SGML parsing is necessary and the local DTD is not extensible.

        In addition, HTTP servers can read the content of the document HEAD to generate response headers corresponding to any elements defining a value for the attribute HTTP-EQUIV. This provides document authors a mechanism (not necessarily the preferred one) for identifying information which should be included in the response headers for an HTTP request.

        The attributes of the META element are: HTTP-EQUIV This attribute binds the element to an HTTP response header. It means that if you know the semantics of the HTTP response header named by this attribute, then you can process the contents based on a well-defined syntactic mapping, whether or not your DTD tells you anything about it. HTTP header names are not case sensitive. If not present, the attribute NAME should be used to identify this metainformation and it should not be used within an HTTP response header. NAME Metainformation name. If not present, the name can be assumed equal to the value of HTTP-EQUIV. CONTENT The metainformation content to be associated with the given name and/or HTTP response header.

        Examples of use


        Tue, 04 Dec 1993 21:29:02 GMT

        Expires: Tue, 04 Dec 1993 21:29:02 GMT Keywords: Fred, Barney, Wilma Reply-to: fielding@ics.uci.edu (Roy Fielding)

        When the HTTP-EQUIV attribute is not present, the server should not generate an HTTP response header for this metainformation; e.g.,

        would not generate an HTTP response header but would still allow clients or other tools to make use of that metainformation.

        Examples of misuse

        One example of an inappropriate usage for the META element is to use it to define information that should be associated with an already existing HTML element, e.g.

        A second example of inappropriate usage is to name an HTTP-EQUIV equal to a response header that should normally only be generated by the HTTP server. Example names that are inappropriate include «Server», «Date», and «Last-modified» — the exact list of inappropriate names is dependent on the particular server implementation. It is recommended that servers ignore any META elements which specify http-equivalents which are equal (case-insensitively) to their own reserved response headers. From: «Roy T. Fielding»
        Date: Sun, 12 Jun 1994 02:21:26 -0700
        Message-Id:

        Источник

        Читайте также:  Create listing file php
Оцените статью