Open In App

SVG RectElement.rx Property

Improve
Improve
Like Article
Like
Save
Share
Report

The SVG RectElement.rx property is used to return an SVGAnimatedLength object corresponding to the attribute of the given rectangle element.

Syntax:

RectElement.rx

Return Values: This property returns an SVGAnimatedLength object that can be used to get the “rx” value and other properties of the rectangle element.

Example 1: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
      
    <h3>SVG RectElement.rx property</h3>
      
    <svg width="300" height="300" 
        xmlns="http://www.w3.org/2000/svg">
  
        <rect width="100" height='190' 
            fill="green" id="gfg" 
            rx=20 ry=10 />
              
        <script>
            var g = document.getElementById("gfg");
            console.log(g.rx)
        </script>
    </svg>
</body>
  
</html>


Output:

Example 2: 

HTML




<!DOCTYPE html>
<html>
  
<body>
    <h1 style="color: green">
        GeeksforGeeks
    </h1>
  
    <h3>SVG RectElement.rx property</h3>
      
    <svg width="300" height="300" 
        xmlns="http://www.w3.org/2000/svg">
          
        <rect width="100" height='190' 
            fill="green" id="gfg" rx=50% ry=10% />
              
        <script>
            var g = document.getElementById("gfg");
            console.log(g.rx);
        </script>
    </svg>
</body>
  
</html>


Output:



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