Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

meta — HTML document metadata

The meta element records metadata such as a page description and an encoding declaration. It can also specify pragma directives or microdata properties. Its meaning depends on the selected attribute.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

<meta charset="utf-8">
<meta name="description" content="Page description">
<meta http-equiv="refresh" content="30">
<div itemscope>
  <meta itemprop="name" content="Example">
</div>

meta describes a document rather than creating visible content. It is a void element: it has no contents or end tag in HTML. It normally belongs in head; the itemprop variant is also allowed where phrasing content is expected.

Specify exactly one of name, http-equiv, charset, or itemprop. name identifies metadata such as description; http-equiv selects a pragma directive; charset declares the encoding; itemprop identifies a microdata property. content is required for the three variants other than charset and must be omitted with charset.

Use charset="utf-8" and actually save the file as UTF-8. The entire declaration must fit within the first 1024 bytes. A document may have only one meta-based encoding declaration; do not combine charset with the http-equiv="content-type" alternative. In XML, the charset attribute has no effect.

http-equiv is not a general substitute for HTTP headers. Authors may use media only with name="theme-color". A document may contain at most one description entry.

The example reads the description's content and displays it in a paragraph. The meta element itself does not render that text.

Examples

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="description" content="A metadata demonstration.">
  <title>Metadata example</title>
</head>
<body>
  <p id="result"></p>
  <script>
    const description = document.querySelector('meta[name="description"]');
    document.getElementById('result').textContent = description.content;
  </script>
</body>
</html>

Result

A metadata demonstration.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources