Open In App

HTML DOM documentElement Property

Last Updated : 02 Sep, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The DOM documentElement property is used to return the documentElement as an Element Object. It is a read-only property. It returns a <HTML> Element. 

Syntax:

document.documentElement 

Return Value: It returns the documentElement of the document or an element object. 

Example: Below program illustrates the documentElement property in HTML: 

HTML
<!DOCTYPE html>
<html>

<head>
    <title>
        DOM documentElement Property
    </title>

    <script>
        function Geeks() {
            let x = document.documentElement.nodeName;
            document.getElementById("sudo").innerHTML = x;
        }
    </script>
</head>

<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>DOM documentElement Property</h2>
        <button onclick="Geeks()">
            Submit
        </button>
        <p id="sudo"></p>
    </center>
</body>

</html>

Output: 

Supported Browsers: The browser supported by DOM documentElement property are listed below:


Next Article

Similar Reads