Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

SVG Element.outerHTML Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The SVG Element.outerHTML property returns innerHTML of the given element.

Syntax:

const content = element.outerHTML

Return value: This property returns outerHTML of the element.

Example 1: 

HTML




<!DOCTYPE html> 
<html
  
<body
    <svg width="350" height="100" 
        xmlns="http://www.w3.org/2000/svg">
  
        <a href="https://www.geeksforgeeks.org" id="gfg">
            <text x='100' y='50' font-size="50px">GfG</text>
        </a>
  
        <script>
            var g = document.getElementById('gfg');
            console.log(g.outerHTML);
        </script>
    </svg>
</body
  
</html>

Output:

Example 2: 

HTML




<!DOCTYPE html> 
<html
  
<body
    <svg width="350" height="500" 
        xmlns="http://www.w3.org/2000/svg">
  
        <a href="https://www.geeksforgeeks.org" id="gfg">
            <circle cx='100' cy='100'r="100"></circle>
        </a>
  
        <script>
            var g = document.getElementById('gfg');
            console.log(g.outerHTML);
        </script>
    </svg>
</body
  
</html>

Output:


My Personal Notes arrow_drop_up
Last Updated : 30 Mar, 2022
Like Article
Save Article
Similar Reads
Related Tutorials