The CSS inset property is shorthand for top, right, bottom, and left. It sets physical offsets on a positioned element; the number and order of values determine which sides receive each offset.
What does CSS inset do?
inset sets the distances between a positioned element and the corresponding edges of its containing block. It is equivalent to setting the four physical offset properties—top, right, bottom, and left—using one shorthand declaration. It does not affect an element whose position is static, the default. MDN’s inset reference documents the property and its syntax.
How do you read the value order?
The values are separated by spaces, not commas. The order follows the same pattern as the margin shorthand:
| Values | Side mapping | Example |
|---|---|---|
| One | All four sides | inset: 12px; |
| Two | Top and bottom; right and left | inset: 12px 24px; |
| Three | Top; right and left; bottom | inset: 8px 16px 24px; |
| Four | Top; right; bottom; left | inset: 8px 12px 16px 20px; |
For four values, remember the clockwise order: top, right, bottom, left.
Outdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstall#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
Copyable CSS inset examples
Offsets work when the element is positioned—for example, with position: absolute, relative, fixed, or sticky. For an absolutely positioned element, the containing block is commonly established by a positioned ancestor.
/* Same offset on every side */
.card {
position: absolute;
inset: 12px;
}
/* Top/bottom 12px; left/right 24px */
.card-paired {
position: absolute;
inset: 12px 24px;
}
/* Top 8px; left/right 16px; bottom 24px */
.card-three-values {
position: absolute;
inset: 8px 16px 24px;
}
/* Top 8px; right 12px; bottom 16px; left 20px */
.card-four-values {
position: absolute;
inset: 8px 12px 16px 20px;
}
/* Fill the containing block */
.overlay {
position: absolute;
inset: 0;
}
An inset value of 0 on all sides makes a positioned overlay reach the containing block’s edges. The element’s sizing and box model still affect its rendered dimensions; use the appropriate sizing rules for the layout you want.
Which values can inset take?
The property accepts lengths, percentages, and auto; it also accepts CSS-wide values such as inherit, initial, revert, revert-layer, and unset. Current syntax references also list newer anchor-related values, but support for newer syntax can differ between browsers. Check compatibility for the exact value and browsers your page must support. MDN lists the current syntax and value details.
Rank #2
How are percentages calculated?
Percentage offsets depend on the side: left and right percentages are relative to the containing block’s width; top and bottom percentages are relative to its height. For example, inset: 10% 5%; sets the top and bottom offsets to 10% of the containing block’s height and the left and right offsets to 5% of its width.
When should you use logical inset properties?
inset always addresses physical top, right, bottom, and left sides. It does not change meaning to follow text direction or writing mode. If the layout should adapt to the inline and block axes, use the logical shorthands inset-inline and inset-block instead. Their start and end sides are determined by writing mode and direction. See MDN’s references for inset-inline and inset-block.
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
/* Physical left and right sides */
.physical {
position: absolute;
inset: 0 1rem;
}
/* Logical inline start and end sides */
.logical {
position: absolute;
inset-inline: 1rem 2rem;
}
Choose the physical shorthand when the design specifically calls for top/right/bottom/left. Choose a logical shorthand when the intended edges are flow-relative and should follow the writing system.
Why might inset appear to do nothing?
- The element is not positioned. Set a suitable non-static
positionvalue;insethas no effect on a non-positioned element. - The containing block is not the one you expect. For absolute positioning, check which ancestor establishes the containing block. A different containing block changes where the offsets are measured from.
- The shorthand order is wrong. With four values, the sequence is top, right, bottom, left; with two, the second value applies to both horizontal sides.
- A percentage is being measured against the wrong dimension. Horizontal sides use the containing block’s width and vertical sides its height.
- You meant flow-relative sides. Use
inset-inlineorinset-blockrather than assuminginsetswitches sides for right-to-left or vertical writing. - The value uses newer syntax. If only an advanced value fails, check support for that value in the target browsers instead of assuming all current syntax is universally available.
Compatibility
MDN marks inset as Baseline Widely available since April 2021. That baseline does not guarantee support for every newer value shown in the current syntax; verify advanced or anchor-related values against the browsers you target. MDN’s compatibility information provides the browser-specific details.
Rank #4
Or skip the browser setup
If you need a website screenshot while checking a page layout, ScreenshotNeo is a screenshot API and MCP server. A single GET request can return an image or PDF; its screenshot endpoint is documented at ScreenshotNeo docs.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server offers screenshot tools for AI agents. The Free plan includes 1,000 screenshots per month without a card; paid plans start at $5 for 3,000.
Sign up for 1,000 free screenshots a month, with no card required.
Best Value
Frequently asked questions
Are commas allowed between inset values?
No. Separate shorthand values with spaces, for example inset: 8px 12px;.
Does inset: 0 mean zero padding?
No. It sets the four positional offsets to zero; padding is controlled by the separate padding property.
Recommended Free Tools
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




