Skip to content
Related Articles

Related Articles

Improve Article

SVG RectElement.rx Property

  • Last Updated : 25 Oct, 2020

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:

Attention reader! Don’t stop learning now. Get hold of all the important Comcompetitivepetitve Programming concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :