rect() and xywh()
The rect() CSS function creates a rectangle at the specified distance from the top and left edges of the containing block. It is a basic shape function of the <basic-shape> data type. You can use the rect() function in CSS properties such as offset-path to create the rectangular path along which an element moves and in clip-path to define the shape of the clipping region.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 119 | 119 | 122 | 17.2 | 119 | 17.2 | |
| CSS type | ||||||
| The xywh() CSS function creates a rectangle using the specified distances from the left (x) and top (y) edges of the containing block and the specified width (w) and height (h) of the rectangle. It is a basic shape function of the basic-shape data type. You can use the xywh() function in CSS properties such as offset-path to create the rectangular path… | 119 | 119 | 122 | 17.2 | 119 | 17.2 |
- This browser only partially implements this feature
- This feature was removed in a later browser version (119)
- Only supported on the `offset-path` property.
- This browser only partially implements this feature
- This feature was removed in a later browser version (119)
- Only supported on the `offset-path` property.
- This browser only partially implements this feature
- This feature was removed in a later browser version (119)
- Only supported on the `offset-path` property.
- This browser only partially implements this feature
- This feature was removed in a later browser version (119)
- Only supported on the `offset-path` property.
- This browser only partially implements this feature
- This feature was removed in a later browser version (119)
- Only supported on the `offset-path` property.
- This browser only partially implements this feature
- This feature was removed in a later browser version (119)
- Only supported on the `offset-path` property.
Syntax
.crop {
clip-path: rect(10px 200px 150px 20px);
}
.highlight {
clip-path: xywh(20px 10px 180px 140px round 8px);
} Live demo
Use cases
-
Decorative enhancement
Use rect() and xywh() to add depth, masking, blending, or special treatment to supporting visuals.
-
Brand expression
Apply effects where the interface benefits from stronger visual identity but still works in simpler environments.
Cautions
- Heavy effects can hurt performance or readability on lower-end devices.
- Do not use visual effects as the only way to communicate meaning or state.
Accessibility
- Maintain text contrast and focus visibility when applying overlays, filters, or blend effects.
- Visual polish should never reduce content legibility.