# How to create a rectangle with rounded corners in HTML5 SVG?

HTMLWeb DevelopmentFront End Technology

SVG stands for Scalable Vector Graphics and is a language for describing 2D-graphics and graphical applications in XML and the XML is then rendered by an SVG viewer. Most of the web browsers can display SVG just like they can display PNG, GIF, and JPG.

To draw a rectangle in HTML SVG, use the SVG <rect> element. For rounded corners, set the rx and ry attribute, which rounds the corners of the rectangle.

## Example

You can try to run the following code to learn how to draw a rectangle with rounded corners in HTML5 SVG.

<!DOCTYPE html>
<html>
<style>
#svgelem {
position: relative;
left: 10%;
-webkit-transform: translateX(-20%);
-ms-transform: translateX(-20%);
transform: translateX(-20%);
}
</style>
<title>SVG</title>

<body>
<h2>HTML5 SVG Rectangle</h2>
<svg id="svgelem" width="300" height="200" xmlns="http://www.w3.org/2000/svg">
<rect x="50" y="20" rx="30" ry="30" width="150" height="150"
style="fill:blue;/">
</svg>
</body>
</html>
Updated on 13-May-2020 10:53:32