Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

CSS inset Property: Syntax and Examples

CSS inset is shorthand for the physical top, right, bottom, and left offsets. Learn its value order, examples, percentage behavior, logical alternatives, and common fixes.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • 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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • 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 position value; inset has 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-inline or inset-block rather than assuming inset switches 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.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.