X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM tagName Property

Element Object Reference Element Object

Example

Get the tagName of an element:

var x = document.getElementById("myP").tagName;

The result of x will be:

P

Try it yourself »

More "Try it Yourself" examples below.


Definition and Usage

The tagName property returns the tag name of the element.

In HTML, the returned value of the tagName property is always in UPPERCASE.

This property is read-only.

Tip: You can also use the nodeName property to return the tag name of an element. The difference is that nodeName also returns attribute nodes, text nodes, comment nodes.


Browser Support

Property
tagName Yes Yes Yes Yes Yes


Syntax

element.tagName

Technical Details

Return Value: A String, representing the tag name of the element in uppercase
DOM Version Core Level 1 Element Object


Examples

More Examples

Example

Using the tagName property together with the event.target property to find out which element triggered a specified event:

var x = event.target.tagName;

Try it yourself »


Related Pages

HTML DOM reference: node.nodeName Property


Element Object Reference Element Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook