Open In App

SVG Document.documentElement Property

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:






<!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:




<!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:


Article Tags :