CSS inset Property
Description
The inset property provides a concise way to express how an element should be offset from the edges of its containing block. Conceptually it acts as a single declaration that controls the element’s offsets on each side instead of setting each edge individually; it is equivalent in intent to using top, right, bottom and left separately, but written in a compact form. Authors use it when they want to position an element relative to its container with fewer lines of CSS while keeping the offsets for all four sides clearly related.
The property only affects elements that participate in positioning; it has no effect on elements in the normal static flow unless their positioning context is changed via position. Unlike box model properties such as margin and padding, which influence layout and the size of the box, inset moves a positioned box relative to its containing block without directly altering its content box dimensions. Because it defines offsets, it interacts with stacking and painting order and is often combined with transforms or composited properties such as transform when building animations or UI transitions.
For internationalized and writing-mode–aware layouts, there are logical counterparts that map the block and inline axes to the physical edges: inset-block and inset-inline. These logical forms are useful when you want an element’s offsets to automatically adapt to different writing directions or vertical text flows without manually switching the physical edge properties.
In practice, inset is handy for implementing overlays, anchored controls, and small UI components that need consistent offsets from their container. Keep in mind that offsets defined by this property are resolved against the containing block and may interact with clipping, overflow, and stacking contexts; for high-performance motion, prefer animating composited properties and be mindful of how offsetting positioned elements affects surrounding layout and hit testing.
Definition
- Initial value
- See individual properties
- Applies to
- positioned elements
- Inherited
- no
- Computed value
- See individual properties
- Animatable
- See individual properties
- JavaScript syntax
- object.style.inset
Interactive Demo
Syntax
inset: <'top'>{1,4}
Values
- <'top'>{1,4}Sets the top, right, bottom, and left properties. Values are assigned to its sub-properties as for margin.
Example
Browser Support
The following information will show you the current browser support for the CSS inset property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
