MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla
Your Search Results

    Element.tagName

    Summary

    Returns the name of the element.

    Syntax

    elementName = element.tagName
    
    • elementName is a string containing the name of the current element.

    Notes

    In XML (and XML-based languages such as XHTML), tagName preserves case. On HTML elements in DOM trees flagged as HTML documents, tagName returns the element name in the uppercase form. The value of tagName is the same as that of nodeName.

    Example

    Given the following markup:

    <span id="born">When I was born...</span>
    

    and the following script

    var span = document.getElementById("born");
    alert(span.tagName);
    

    In XHTML (or any other XML format), "span" would be alerted. In HTML, "SPAN" would be alerted instead.

    Specifications

    Document Tags and Contributors

    Last updated by: fscholz,
    Hide Sidebar