Latest web development tutorials

HTML DOM nodeName property

Elements Object Reference Element object

Examples

Get node name body element:

document.body.nodeName;

Output:

BODY

try it"

Definition and Usage

nodeName property returns the name depending on the type of node.

If the node is an element node, nodeName property returns the tag name.

If the node is an attribute node, nodeName property returns the attribute name.

Other node types, nodeName property returns back to a different node name depending on the node type.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support nodeName property


grammar

node .nodeName

technical details

return value: String representing the name of the node.
DOM version Core Level 1 Node Object


Elements Object Reference Element object