SVG Document.documentElement Property

Last Updated : 30 Mar, 2022

The SVG Document.documentElement property returns the root element of the document.

Syntax:

const element = document.documentElement

Return value: This property returns the root element of the document.

Example 1:

HTML
<!DOCTYPE html>
<html>

<body>
    <svg width="350" height="500" 
        xmlns="http://www.w3.org/2000/svg">
        
        <circle cx="100" cy="100" r="50"></circle>
        
        <script>
            console.log(document.documentElement)
        </script>
    </svg>
</body>

</html>

Output:

Example 2:

HTML
<!DOCTYPE html>
<html>

<body>
    <svg width="350" height="500" 
        xmlns="http://www.w3.org/2000/svg">
        
        <text x="20" y="20">GeeksforGeeks</text>
        
        <script>
            console.log(document.documentElement)
        </script>
    </svg>
</body>

</html>

Output:

Comment