The short answer
In SVG, <circle> draws a circle from its center (cx, cy) and radius (r), and <rect> draws a rectangle from its top-left corner (x, y), width and height, with optional rounded corners (rx, ry). Both accept fill and stroke attributes and live inside an <svg> element with a viewBox.
A minimal example
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 200 120" width="200" height="120">
<rect x="10" y="10" width="110" height="100" rx="12" fill="#243d2e"/>
<circle cx="150" cy="60" r="40" fill="#c74b31" stroke="#202721" stroke-width="4"/>
</svg>Paste this into the free SVG editor to see it and experiment with the values.
Circle attributes
| Attribute | Meaning |
|---|---|
| cx, cy | Center point in user units |
| r | Radius |
| fill | Interior color, or none |
| stroke, stroke-width | Outline color and thickness |
Rect attributes
| Attribute | Meaning |
|---|---|
| x, y | Top-left corner |
| width, height | Size; zero hides the shape |
| rx, ry | Corner radii for rounded rectangles |
| fill, stroke | Paint, as for every shape |
The viewBox controls scaling
viewBox="0 0 200 120" defines the internal coordinate system. The width and height attributes, or CSS, set how large it appears. Remove width and height to let the SVG fill its container while keeping proportions.
Other basic shapes
- <ellipse cx cy rx ry> for ovals.
- <line x1 y1 x2 y2> for a single line; it needs a stroke to be visible.
- <polygon points> for closed shapes and <polyline points> for open ones.
- <path d> for anything, including curves; traced images use paths.
Sources
Written by Shahab Uddin. Published ; updated . Corrections are welcome through the contact page.