Open In App

SVG Document.documentElement Property

Last Updated : 30 Mar, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

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:



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads