HTML DOM Element tagName

Examples

Get the tagName of the "demo" element:

let name = document.getElementById("demo").tagName;
Try it Yourself »

Find which element triggered an event:

const element = event.target;
let name = element.tagName;
Try it Yourself »

Description

The tagName property returns the tag name of an element.

The tagName property returns the tag name in UPPERCASE.

The tagName property is read-only.

Difference Between tagName and nodeName

The nodeName property also returns the tag name of an element.

The nodeName can also return the tag name of attribute nodes, text nodes, and comment nodes.

See Also:

The nodeName Property

The nodeType Property

The nodeValue Property


Syntax

element.tagName

Return Value

Type Description
StringThe tag name of the element (in uppercase).

Browser Support

element.tagName is a DOM Level 1 (1998) feature.

It is fully supported in all browsers:

Chrome Edge Firefox Safari Opera IE
Yes Yes Yes Yes Yes 9-11

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.