files/en-us/web/api/htmlmetaelement/content/index.md
{{APIRef("HTML DOM")}}
The HTMLMetaElement.content property gets or sets the content attribute of pragma directives and named {{htmlelement("meta")}} data in conjunction with {{domxref("HTMLMetaElement.name")}} or {{domxref("HTMLMetaElement.httpEquiv")}}.
For more information, see the content attribute.
A string.
The following example queries a <meta> element that contains a name attribute with the value of keywords.
The content value is logged to the console to display the keywords of the document:
// given <meta name="keywords" content="documentation, HTML, web">
const meta = document.querySelector("meta[name='keywords']");
console.log(meta.content);
// "documentation, HTML, web"
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);
{{Specifications}}
{{Compat}}