CSS Reference ยท Functions
Basic shapes: circle(), ellipse(), inset(), polygon(), path()
Reference for CSS basic shape functions inset, circle, ellipse, polygon and path: syntax, units, positions, use in clip-path and shape-outside, with examples.
The basic-shape functions describe a geometric outline: a rounded rectangle, a circle, an ellipse, a polygon or a free-form path. They are not drawn by themselves. You pass them to properties that need a shape, mainly clip-path (cut the element to the shape), shape-outside (wrap text around it) and offset-path (move an element along it).
.avatar { clip-path: circle(50%); }
Try it
Syntax
inset( <length-percentage>{1,4} [round <border-radius>]? ) circle( [<radius>]? [at <position>]? ) ellipse( [<radius>{2}]? [at <position>]? ) polygon( [<fill-rule>,]? [<x> <y>]# ) path( [<fill-rule>,]? "<SVG path data>" )
Each can be followed by a reference box keyword in clip-path (for example circle(50%) padding-box).
Values
| Function | Description |
|---|---|
inset(t r b l round r) |
A rectangle inset from each edge of the reference box, like margin shorthand. round adds corner radii. |
circle(r at x y) |
Radius r (length, percentage or closest-side / farthest-side; default closest-side), center position (default the middle). A percentage radius refers to sqrt(wยฒ + hยฒ) / sqrt(2) of the box. |
ellipse(rx ry at x y) |
Like circle() with two radii. Percentages refer to the box width and height. |
polygon(x y, x y, ...) |
Straight-edged shape through listed points. Optional nonzero or evenodd fill rule first. |
path("...") |
SVG path commands in a quoted string. Coordinates are in pixels from the top-left of the reference box and do not scale with the element. |
Usage notes
- Reference box. Percentages and coordinates are measured against a box: for
clip-pathit defaults to the border box, forshape-outsideto the margin box. - Clipping hides everything outside, including borders, shadows and focus outlines, and the clipped area no longer receives clicks.
path()does not scale. For responsive shapes preferpolygon()with percentages, or use an SVG withclipPathandobjectBoundingBoxunits.- Animation. Two shapes of the same function with the same number of points interpolate smoothly, which is great for transitions between polygons.
shape-outsideneeds a float and a box with dimensions.- A newer
shape()function exists for responsive, path-like shapes; support is limited, so check a compatibility table before using it.
Browser support
inset(), circle(), ellipse() and polygon() work in all current browsers. path() in clip-path is also supported in current browsers; verify older versions in a compatibility table.