Rectangles in SVG: <rect>

While this tutorial has content that we believe is of great benefit to our community, we have not yet tested or edited it to ensure you have an error-free learning experience. It's on our list, and we're working on it! You can help us out by using the "report an issue" button at the bottom of the tutorial.

Defining rectangles in svg:

<svg xmlns="http://www.w3.org/2000/svg"
    viewBox="0 0 1000 200">

  <rect x="349" y="67"
      width="302" height="66"
      rx="5" ry="5"
      stroke-width="2" />

Breaking it down

Here are the properties used to define rectangles. If you omit rx and ry the corner radius will default to 0:

  • x & y: The x and y position of the top left corner of the rectangle.
  • width & height: The width and height of the rectangle.
  • rx & ry: Corner radius.
Creative Commons License