Favorites

DOM Element.tagName Property

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee
Element.tagName
DOM Element PropertyThis property is supported by all modern browsers.
Updated 28th November 2026

The tagName property returns the name of an element's tag, in upper case for HTML elements.

Description

The read-only tagName property returns the element's tag name. For HTML elements in HTML documents it's upper case ("BUTTON"), while SVG elements keep their original case. To check an element's type, matches('button') or instanceof HTMLButtonElement avoid case issues.

It's the same as nodeName for elements. For custom elements, the tag name includes the hyphen, such as "MY-WIDGET", and you can find their registered class with customElements.get().

Comparing tag names is handy in generic code, such as event delegation that treats links differently from buttons, but matches() lets you check tag names, classes and attributes in one go.

Syntax

element.tagName

Value

The element's tag name, in upper case for HTML elements, such as "DIV".

Example

<h2>Title</h2>
<p>Text</p>
<button type="button">Go</button>
document.querySelectorAll('body > *').forEach(el => console.log(el.tagName));
console.log(document.querySelector('p').tagName.toLowerCase());

Browser Support

The following information will show you the current browser support for the Element.tagName property. Hover over a browser icon to see the version that first introduced support for this property.

This property is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee