Open In App

SVG prefix Property

Improve
Improve
Like Article
Like
Save
Share
Report

The SVG prefix property returns prefix of the given Attr Element

Syntax:

string = attribute.prefix

Return value: This property returns the prefix of the Attr.

Example 1: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 100 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <!-- A link around a text -->
        <text id="example" x="20" y="20">
            Click me
        </text>
          
        <script>
            const element = document
                .querySelector("#example");
                  
            const attribute = element.attributes[0];
            console.log(attribute.prefix);
        </script>
    </svg>
</body>
  
</html>


Output:


Example 2: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <svg viewBox="0 0 100 100" 
        xmlns="http://www.w3.org/2000/svg">
          
        <!-- A link around a shape -->
        <circle id="example" cx="20" 
            cy="20" r="15">
            Click me
        </circle>
          
        <script>
            const element = document
                .querySelector("#example");
                  
            const attribute = element.attributes[0];
            console.log(attribute.prefix);
        </script>
    </svg>
</body>
  
</html>


Output:




Last Updated : 30 Mar, 2022
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads