[ Web Proxy ]
URL:
Viewing: https://angular.dev/api/platform-browser/Meta [Back]  [Original]

Meta Angular Skip to main content
menu
close
more_horiz
menuAPI
@angular/platform-browser

Meta

Class
stable

A service for managing HTML <meta> tags.

HTML meta tagDocument.querySelector()

On this page

    arrow_upward_alt Back to the top

    API

        
          class Meta {  addTag(tag: MetaDefinition, forceCreation?: boolean): HTMLMetaElement | null;  addTags(tags: MetaDefinition[], forceCreation?: boolean): HTMLMetaElement[];  getTag(attrSelector: string): HTMLMetaElement | null;  getTags(attrSelector: string): HTMLMetaElement[];  updateTag(tag: MetaDefinition, selector?: string | undefined): HTMLMetaElement | null;  removeTag(attrSelector: string): void;  removeTagElement(meta: HTMLMetaElement): void;}
        
        

    addTag

    HTMLMetaElement | null

    Retrieves or creates a specific <meta> tag element in the current HTML document. In searching for an existing tag, Angular attempts to match the name or property attribute values in the provided tag definition, and verifies that all other attribute values are equal. If an existing element is found, it is returned and is not modified in any way.

    @paramtagMetaDefinition

    The definition of a <meta> element to match or create.

    @paramforceCreationboolean

    True to create a new element without checking whether one already exists.

    @returnsHTMLMetaElement | 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.

    addTags

    HTMLMetaElement[]

    Retrieves or creates a set of <meta> tag elements in the current HTML document. In searching for an existing tag, Angular attempts to match the name or property attribute values in the provided tag definition, and verifies that all other attribute values are equal.

    @paramtagsMetaDefinition[]

    An array of tag definitions to match or create.

    @paramforceCreationboolean

    True to create new elements without checking whether they already exist.

    @returnsHTMLMetaElement[]

    The matching elements if found, or the new elements.

    getTag

    HTMLMetaElement | null

    Retrieves a <meta> tag element in the current HTML document.

    @paramattrSelectorstring

    The tag attribute and value to match against, in the format "tag_attribute='value string'".

    @returnsHTMLMetaElement | null

    The matching element, if any.

    getTags

    HTMLMetaElement[]

    Retrieves a set of <meta> tag elements in the current HTML document.

    @paramattrSelectorstring

    The tag attribute and value to match against, in the format "tag_attribute='value string'".

    @returnsHTMLMetaElement[]

    The matching elements, if any.

    updateTag

    HTMLMetaElement | null

    Modifies an existing <meta> tag element in the current HTML document.

    @paramtagMetaDefinition

    The tag description with which to replace the existing tag content.

    @paramselectorstring | undefined

    A tag attribute and value to match against, to identify an existing tag. A string in the format "tag_attribute=value string". If not supplied, matches a tag with the same name or property attribute value as the replacement tag.

    @returnsHTMLMetaElement | null

    removeTag

    void

    Removes an existing <meta> tag element from the current HTML document.

    @paramattrSelectorstring

    A tag attribute and value to match against, to identify an existing tag. A string in the format "tag_attribute=value string".

    @returnsvoid

    removeTagElement

    void

    Removes an existing <meta> tag element from the current HTML document.

    @parammetaHTMLMetaElement

    The tag definition to match against to identify an existing tag.

    @returnsvoid

    Description

    A service for managing HTML <meta> tags.

    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}].

    Jump to details

    Web Proxy Viewer  |  New URL  |  Original Page