HTMLMetaElement: content property
HTML DOM
HTML DOM
The **`HTMLMetaElement.content`** property gets or sets the `content` attribute of pragma directives and named meta data in conjunction with HTMLMetaElement.name or HTMLMetaElement.httpEquiv.
For more information, see the [content](/docs/Web/HTML/Reference/Elements/meta#content) attribute.
## Value
A string.
## Examples
### Reading meta element content
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](/docs/Web/HTML/Reference/Elements/meta/name#meta_names_defined_in_the_html_specification) of the document:
```js
// given <meta name="keywords" content="documentation, HTML, web">
const meta = document.querySelector("meta[name='keywords']");
console.log(meta.content);
// "documentation, HTML, web"
```
### Creating a meta element with content
The following example creates a new `<meta>` element with a `name` attribute set to [`description`](/docs/Web/HTML/Reference/Elements/meta/name#meta_names_defined_in_the_html_specification).
The `content` attribute sets a description of the document and is appended to the document `<head>`:
```js
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
## Browser compatibility
## See also
- meta
- HTMLMetaElement.name
- HTMLMetaElement.httpEquiv
- [Learn: Metadata in HTML](/docs/Learn_web_development/Core/Structuring_content/Webpage_metadata#metadata_the_meta_element)
Cite this
"HTMLMetaElement: content property". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/HTMLMetaElement/content JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy