files/en-us/web/api/htmlmetaelement/index.md
{{ APIRef("HTML DOM") }}
The HTMLMetaElement interface contains descriptive metadata about a document provided in HTML as <meta> elements.
This interface inherits all of the properties and methods described in the {{domxref("HTMLElement")}} interface.
{{InheritanceDiagram}}
Inherits properties from its parent, {{domxref("HTMLElement")}}.
theme-color metadata property.No specific method; inherits methods from its parent, {{domxref("HTMLElement")}}.
The following two examples show a general approach to using the HTMLMetaElement interface.
For specific examples, see the pages for the individual properties as described in the Instance properties section above.
The following example creates a new <meta> element with a name attribute set to description.
The content attribute sets a description of the document and is appended to the document <head>:
const meta = document.createElement("meta");
meta.name = "description";
meta.content =
"The <meta> element can be used 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.";
document.head.appendChild(meta);
The following example shows how to create a new <meta> element with a name attribute set to viewport.
The content attribute sets the viewport size and is appended to the document <head>:
const meta = document.createElement("meta");
meta.name = "viewport";
meta.content = "width=device-width, initial-scale=1";
document.head.appendChild(meta);
For more information on setting the viewport, see <meta name="viewport">.
{{Specifications}}
{{Compat}}