inset() CSS Function
The inset() function defines a rectangle by moving each edge inwards from the element's edges, with optional rounded corners, used by clip-path.
Description
The inset() CSS function defines a rectangle as a <basic-shape> by moving each edge inward from the edges of the element's reference box. It is used with the clip-path property to show only a rectangular part of an element, with shape-outside to wrap text around a rectangle, and with offset-path. It is not the same as the inset property, which is a shorthand for top, right, bottom and left on positioned elements.
The offsets follow the same pattern as the margin shorthand. One value moves all four edges inward by the same amount; two values set top and bottom, then left and right; three values set top, left and right, then bottom; and four values set top, right, bottom and left in clockwise order. Offsets can be lengths or percentages of the reference box. Adding the keyword round followed by border-radius values gives the rectangle rounded corners.
Because the offsets are measured inward from each edge, inset(0) shows the whole element and larger values crop more. This makes inset() ideal for reveal animations: transitioning from inset(0 100% 0 0) to inset(0) wipes the element into view from left to right.
/* Crop 10% from top and bottom, 5% from the sides, with rounded corners */
.photo {
clip-path: inset(10% 5% round 16px);
}
/* Wipe in from the left on hover */
.reveal {
clip-path: inset(0 100% 0 0);
transition: clip-path 0.5s ease;
}
.reveal:hover {
clip-path: inset(0);
}
Related rectangle functions are rect(), which measures edges from the top and left, and xywh(), which uses a position and a size.
Interactive Demo

Syntax
inset() = inset( <length-percentage>{1,4} [ round <'border-radius'> ]? )Values
- offsetWhen all of the first four arguments are supplied they represent the top, right, bottom and left offsets from the reference box inward that define the positions of the edges of the inset rectangle. These arguments follow the syntax of the margin shorthand, that let you set all four insets with one, two or four values.
- border-radiusdefine rounded corners for the inset rectangle using the border-radius shorthand syntax
Example
Browser Support
The following information will show you the current browser support for the CSS inset() function. Hover over a browser icon to see the version that first introduced support for this CSS function.
Desktop





Tablets & Mobile





