On this page
Meta
class
A service for managing HTML <meta> tags.
class Meta {
addTag(tag: MetaDefinition, forceCreation: boolean = false): HTMLMetaElement | null
addTags(tags: MetaDefinition[], forceCreation: boolean = false): HTMLMetaElement[]
getTag(attrSelector: string): HTMLMetaElement | null
getTags(attrSelector: string): HTMLMetaElement[]
updateTag(tag: MetaDefinition, selector?: string): HTMLMetaElement | null
removeTag(attrSelector: string): void
removeTagElement(meta: HTMLMetaElement): void
}
See also
Provided in
'root'
Description
Properties of the MetaDefinition object match the attributes of the HTML <meta> tag. These tags define document metadata that is important for things like configuring a Content Security Policy, defining browser compatibility and security settings, setting HTTP Headers, defining rich content for social sharing, and Search Engine Optimization (SEO).
To identify specific <meta> tags in a document, use an attribute selection string in the format "tag_attribute='value string'". For example, an attrSelector value of "name='description'" matches a tag whose name attribute has the value "description". Selectors are used with the querySelector() Document method, in the format meta[{attrSelector}].
Methods
|
addTag()
|
||||||
|---|---|---|---|---|---|---|
Retrieves or creates a specific |
||||||
|
tag |
MetaDefinition |
The definition of a |
forceCreation |
boolean |
True to create a new element without checking whether one already exists. Optional. Default is |
Returns
HTMLMetaElement | null: The existing element with the same attributes and values if found, the new element if no match is found, or null if the tag parameter is not defined.
|
|
||||||
|---|---|---|---|---|---|---|
Retrieves or creates a set of |
||||||
|
tags |
MetaDefinition[] |
An array of tag definitions to match or create. |
forceCreation |
boolean |
True to create new elements without checking whether they already exist. Optional. Default is |
Returns
HTMLMetaElement[]: The matching elements if found, or the new elements.
|
getTag()
|
|||
|---|---|---|---|
Retrieves a |
|||
|
attrSelector |
string |
The tag attribute and value to match against, in the format |
Returns
HTMLMetaElement | null: The matching element, if any.
|
|
|||
|---|---|---|---|
Retrieves a set of |
|||
|
attrSelector |
string |
The tag attribute and value to match against, in the format |
Returns
HTMLMetaElement[]: The matching elements, if any.
|
updateTag()
|
||||||
|---|---|---|---|---|---|---|
Modifies an existing |
||||||
|
tag |
MetaDefinition |
The tag description with which to replace the existing tag content. |
selector |
string |
A tag attribute and value to match against, to identify an existing tag. A string in the format Optional. Default is |
Returns
HTMLMetaElement | null: The modified element.
|
removeTag()
|
|||
|---|---|---|---|
Removes an existing |
|||
|
attrSelector |
string |
A tag attribute and value to match against, to identify an existing tag. A string in the format |
Returns
void
|
removeTagElement()
|
|||
|---|---|---|---|
Removes an existing |
|||
|
meta |
HTMLMetaElement |
The tag definition to match against to identify an existing tag. |
Returns
void
© 2010–2021 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
https://v11.angular.io/api/platform-browser/Meta