HTML/jp/Elements/meta

From W3C Wiki

<meta>

<meta>要素は、<title>や<base>、<link>、<style>、<script>を使って表現のできない様々なメタデータをあらわします。

ポイント

  • name属性、http-equiv属性、charset属性のうち一つは指定しなければなりません。
  • もしname属性かhttp-equiv属性が指定された場合、content属性も指定しなければなりません。そうでなければ、それは省略されなければなりません。


コンテンツ属性

  • 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. [例題 A]
    • generator
      Identifies one of the software packages used to generate the document.
    • keywords
      Giving the keyword relevant to the page. [例題 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. [例題 B]


  • content = string
    Gives the value of the document metadata or pragma directive when the element is used for those purposes.


  • charset = character encoding name
    Specifies the character encoding used by the document. [例題 A]


グローバル属性も参照してください。

例題

例題 A

<head>
  <title>World Wide Web Consortium (W3C)</title>
  <meta charset=utf-8" />
  <meta name="description"
        content="The World Wide Web Consortium (W3C) is an international community
        where Member organizations, a full-time staff,
        and the public work together to develop Web standards." />
  <meta name="keyword" content="W3C, HTML, CSS, SVG, Web standards">
</head>

例題 B

ニュース配信サイトなどのトップページでは、<head>要素に以下のようなマークアップが含まれることがあります。このページは5分毎にサーバーから自動的にリロードされることになります。

<meta http-equiv="Refresh" content="300">

HTML仕様書

<meta>要素は、HTML5仕様書の4.2.5 The meta elementに定義されています。