<rect x y width height rx ry />
-
The
rect
element is a basic SVG
shape that draws
rectangles
, defined by their position
, width
, and
height
-
The
rectangles
may have their corners rounded
-
x
-
The
x
coordinate of rect
-
value type
length
percentage
-
default value:
0
-
y
-
The
y
coordinate of rect
-
value type
length
percentage
-
default value:
0
-
width
-
The
width
of rect
-
value type
auto
length
percentage
-
default value:
auto
-
height
-
The
height
of rect
-
value type
auto
length
percentage
-
default value:
auto
-
rx
-
The horizontal corner
radius
of rect
-
Defaults to
ry
if it is specified
-
value type
:
auto
length
percentage
-
default value:
auto
-
ry
-
The vertical corner
radius
of the rectangle
-
Defaults to
rx
if it is specified
-
value type
: auto
, length
or
percentage
-
pathLength
-
The total length of the rectangle's perimeter, in user units
-
value type:
number
- default value:
none
-
Starting with
SVG2
, x
, y
, width
,
height
, rx
and ry
are Geometry
Properties, meaning those attributes can also be used as CSS properties for
that element.
HTML
<div class="flex_container">
<object
data="../svg/svg_example_one.svg"
type="image/svg+xml">
</object>
</div>
SVG
// svg_example_one.svg
<svg version= "1.1"
width = "300"
height = "150"
xmlns = "http://www.w3.org/2000/svg">
<rect width="100%"
height="100%"
fill="lightgoldenrodyellow" />
<rect x="10"
y="10"
width="50%"
height="66.666%"
fill="blue" />
<rect x="20"
y="20"
width="13.333%"
height="26.666%" fill="lightgoldenrodyellow" />
<rect x="240"
y="90"
width="13.333%"
height="26.666%"
stroke="red"
stroke-width="2"
fill="none" />
</svg>