HTML Element: <meta>
[this page | pdf | back links]
The
HTML <meta> element indicates metadata
about an HTML document. Metadata is not displayed on the page but is machine
readable. The <meta> element
always goes within the <head>
element. Metadata within a <meta>
element are always passed in pairs, one part describing what type of metadata
is involved, the other indicating the value to ascribe to the metadata.
For example, the
following are uses of the <meta>
element:
Use to which a
specific <meta>
element can be put
|
Example
|
Page author
|
<meta name="author" content="Nematrian">
|
Page description
|
<meta name="description" content="HTML meta element">
|
Page keywords (used by search
engines)
|
<meta name="keywords" content="HTML, Reference, Metadata">
|
Page to refresh every say
60 seconds
|
<meta http-equiv="refresh" content="60">
|
Page viewport that aims
to make webpage look good on all devices
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
In HTML 5 a viewport
metadata component was introduced (see above), allowing webpage designers
greater control over the user’s viewing experience, i.e. how the browser
handles the browser window within which the page is viewed.
The attributes it can take
(other than HTML
global attributes and HTML event attributes)
include:
Attribute
|
Description
|
More
|
charset
|
Specifies character
encoding
|
Here
|
content
|
Value associated with
the http-equiv
or name
attribute
|
Here
|
http-equiv
|
HTTP header for
information/value of attribute
|
Here
|
name
|
Name of piece of
metadata
|
Here
|
The element used to
support the scheme attribute,
but this is no longer supported in HTML 5.
To create or access such an element in JavaScript
see here. The
corresponding HTML DOM
object supports standard
DOM properties and methods, and additional properties with the same name and
meaning as the attributes of the underlying HTML element referred to above
(with the http-equiv property of
the underlying element corresponding to the httpEquiv
property of the DOM object). The default style applicable to this element is
shown here.
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<meta name="description" content="Nematrian meta element (JavaScript example)">
</head>
<body>
Created using HTML:<br>
<span>A meta element indicating document author is included in this document</em>
<br><br>Created using JavaScript:<br>
<em>with content: <span id="element"></span></em>
<script>
var x = document.getElementsByTagName("META")[0].content;
document.getElementById("element").innerHTML = x;
</script>
</body>
</html>
|
NAVIGATION LINKS
Contents | Prev | Next | HTML Elements