xywh() CSS Function
The xywh() function defines a rectangle by the x and y position of its top-left corner and its width and height, used by clip-path.
Description
The xywh() CSS function defines a rectangle by its position and size: the x and y coordinates of its top-left corner, followed by its width and height. It is a <basic-shape> used with clip-path, offset-path and shape-outside. Many people find it more natural than inset() or rect() because it matches how rectangles are described in design tools and in the SVG rect element.
The x and y values are measured from the top-left corner of the reference box, and can be lengths or percentages. The width and height must not be negative. Because the size is given directly, moving the rectangle only requires changing x and y, which makes xywh() convenient for animating a "window" that slides across an element. An optional round keyword followed by border-radius values rounds the corners.
/* A 200 x 120 window, 20px from the top-left corner */
.thumb {
clip-path: xywh(20px 20px 200px 120px);
}
/* Centered half-size rectangle with rounded corners */
.focus {
clip-path: xywh(25% 25% 50% 50% round 16px);
}
Interactive Demo

Syntax
xywh() = xywh( <length-percentage>{2} <length-percentage [0,∞]>{2} [ round <'border-radius'> ]? )Values
- xThe horizontal distance of the rectangle's left edge from the left of the reference box, as a <length-percentage>.
- yThe vertical distance of the rectangle's top edge from the top of the reference box, as a <length-percentage>.
- widthThe width of the rectangle, as a non-negative <length-percentage>.
- heightThe height of the rectangle, as a non-negative <length-percentage>.
- round <'border-radius'>Optional. Rounds the corners of the rectangle using border-radius syntax.
Example
Browser Support
The following information will show you the current browser support for the CSS xywh() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





