DOM Element.tagName Property
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.tagNameValue
The element's tag name, in upper case for HTML elements, such as "DIV".
Example
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.
Desktop





Tablets & Mobile





