Favorites

inset() CSS Function

inset()
CSS FunctionThis function is supported by all modern browsers.
Updated 21st November 2026

The inset() function defines a rectangle by moving each edge inwards from the element's edges, with optional rounded corners, used by clip-path.

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.

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

Sunset
Demo Code
HTML Code
<img class="demo-element" src="/css-properties/images/sunset.jpg" alt="Sunset">
CSS Code
.demo-element {
	width: 260px;
	display: block;
	border-radius: 6px;
	clip-path: inset(0);
}

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

<div class="container">
<img src="https://picsum.photos/id/10/400/300" alt="Landscape" class="clipped-element">
</div>
.clipped-element {
width: 400px;
height: 300px;
display: block;

/* inset(top right bottom left round border-radius) */
clip-path: inset(20px 50px 20px 50px round 20px);

transition: clip-path 0.4s ease;
}

/* Hover effect to show the original size */
.clipped-element:hover {
clip-path: inset(0px 0px 0px 0px round 0px);
}
Open in editor

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.

This function is supported by all modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported

Looks like you're using an ad blocker, and that's fine! Ads help keep CSS Portal's generators and references free, so if the site's useful to you, visit our Support page to see other ways to help.