CSS inset Property Explained
What the CSS inset property does, with an example.
Published November 7, 2026
inset is a shorthand for top, right, bottom and left. inset: 0 stretches a positioned element to fill its containing block.
How it works
Like margin it accepts 1–4 values. It requires a positioned element (relative, absolute, fixed or sticky).
inset-inline and inset-block are logical versions.
Values and effects
inset: 0; → all four sides at 0
inset: 10px 20px; → vertical, horizontal
inset: auto; → unset
Practical examples
Full overlay
.overlay { position: fixed; inset: 0; }Anchored badge
.badge { position: absolute; inset: -4px -4px auto auto; }Logical
.panel { position: absolute; inset-inline: 0; inset-block-start: 0; }Common mistakes
- Using it on static elements (no effect).
- Forgetting auto for sides you don't want fixed.
- Confusing it with padding.
Key takeaways
- inset in one line: inset is a shorthand for top, right, bottom and left.
- Inspect it live in DevTools → Styles.
- Test across browsers and screen sizes.
FAQ
inset vs top/left?
inset is just a shorthand for all four offsets.
Is inset supported in all browsers?
Yes in all modern browsers; check caniuse.com for edge cases.