CSS inset-block Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The inset-block property is a shorthand for inset-block-start and inset-block-end. It sets offsets along the block axis.

In the default horizontal writing mode that usually means top and bottom. With writing-mode: vertical-rl, the same values map to the physical right and left edges. It only affects positioned elements. For the other axis, use inset-inline. Physical four-side shorthand is inset.

Baseline · Widely available.

Not deprecated and not experimental. Logical inset properties have been widely available across browsers since April 2021. Internet Explorer does not support them.

CSS Syntax

syntax.css
inset-block: <length> | <percentage> | auto | initial | inherit;

One value sets start and end the same. Two values set start first and end second. Each longhand starts as auto. The property is not inherited.

Property Values

ValueDescriptionTry it
One valueSame offset on block-start and block-endTry it
Two valuesFirst = block-start, second = block-endTry it
With writing-modePhysical edges change when writing mode is verticalTry it
Needs positionWithout a positioned value, inset-block does nothingTry it
initialResets both sides to autoTry it
inheritUses the parent’s inset-block valueTry it

How to Use inset-block

Position the element, then set block-axis offsets.

  1. Make a containing block if needed (position: relative on the parent).
  2. Set the child to position: absolute (or another non-static value).
  3. Add inset-block with one or two lengths/percentages.
  4. Optionally set writing-mode to see the offsets map to different physical edges.
PieceRequired?Role
position ≠ staticYesWithout it, inset-block is ignored
1–2 valuesYesOne = both sides; two = start then end
writing-modeOptionalChanges which physical edges get the offsets
Inline axisSeparateUse inset-inline for the other axis

Live Preview

The blue box is position: absolute. Change only inset-block. Left/right stay at auto unless you stretch elsewhere.

In horizontal text, these offsets act like top and bottom.

Box

inset-block: 16px

CSS Examples

Each snippet focuses on inset-block. Position is required so the offsets apply. Use Try It Yourself for a live editor.

Example 1 — Same Offset on Both Block Sides

In horizontal text, this insets top and bottom equally.

CSS
<style>
  .stage { position: relative; height: 140px; border: 1px dashed #94a3b8; }
  .box {
    position: absolute;
    left: 16px;
    right: 16px;
    inset-block: 16px;
    background: #2563eb;
    color: #fff;
  }
</style>

<div class="stage">
  <div class="box">inset-block: 16px</div>
</div>
Try It Yourself

How It Works

  1. Position the child. absolute inside a relative stage.
  2. Set both block sides. One value applies to start and end.
  3. Map in horizontal mode. That means top and bottom get 16px.
  4. Give inline size separately. left/right (or inset-inline) span the width here.

Example 2 — Different Start and End

First value is block-start. Second is block-end.

CSS
<style>
  .stage { position: relative; height: 140px; border: 1px dashed #94a3b8; }
  .box {
    position: absolute;
    left: 16px;
    right: 16px;
    inset-block: 8px 32px;
    background: #2563eb;
    color: #fff;
  }
</style>

<div class="stage">
  <div class="box">8px start, 32px end</div>
</div>
Try It Yourself

How It Works

  1. Pass two lengths. Order is start, then end.
  2. Smaller start gap. 8px on block-start (top in horizontal text).
  3. Larger end gap. 32px on block-end (bottom here).
  4. Same property, two jobs. You do not need separate start/end longhands for this pattern.

Example 3 — Vertical Writing Mode

With vertical-rl, block offsets map to the right and left edges.

CSS
<style>
  .stage {
    position: relative;
    height: 160px;
    border: 1px dashed #94a3b8;
    writing-mode: vertical-rl;
  }
  .box {
    position: absolute;
    inset-inline: 12px;
    inset-block: 16px 32px;
    background: #2563eb;
    color: #fff;
  }
</style>

<div class="stage">
  <div class="box">Follows block axis</div>
</div>
Try It Yourself

How It Works

  1. Switch writing mode. vertical-rl turns the block axis sideways.
  2. Keep the same logical rule. inset-block still means start and end on the block axis.
  3. Physical edges change. Those offsets now land on right and left.
  4. Why logical helps. One rule works in horizontal and vertical layouts.

Edge Cases & Pitfalls

If the offsets look wrong, check these first.

position

Static elements ignore inset-block

Set position to relative, absolute, fixed, or sticky first.

axis

Only the block axis

This property never sets left/right in horizontal text. Use inset-inline for the inline axis, or inset for all four physical sides.

order

Two values are start then end

inset-block: 8px 32px means 8px on block-start and 32px on block-end. Swap them if the wrong edge looks wrong.

mode

Writing mode changes the physical edges

Do not assume “always top and bottom.” Check writing-mode when the layout is vertical.

physical

inset is physical; this is logical

inset always maps to top/right/bottom/left. Prefer inset-block when the block axis should follow writing mode.

Browser Support

inset-block is a browser CSS property for logical positioned offsets. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available

inset-block

Chrome 87+, Edge 87+, Firefox 63+, Safari 14.1+. Internet Explorer has no support — fall back to top/bottom (or left/right in vertical modes).

96% Modern browser support
Google Chrome 87+
Full support
Mozilla Firefox 63+
Full support
Apple Safari 14.1+
Full support
Microsoft Edge 87+
Full support
Opera 73+
Full support
Samsung Internet 14+
Full support
Internet Explorer No support
Not supported
inset-block Widely supported

Bottom line: Safe for modern sites. For Internet Explorer, use top and bottom (or the matching physical pair). It is not a runtime API.

Key Takeaways

  • Role: set logical block-start and block-end offsets together.
  • Needs position: relative, absolute, fixed, or sticky.
  • One or two values: one for both sides; two for start then end.
  • Follows writing mode: not always top/bottom physically.

One line: positioned box + inset-block: 8px 32px; = logical block offsets that adapt with writing mode.

Frequently Asked Questions

It is a shorthand for inset-block-start and inset-block-end. It sets logical offsets along the block axis of a positioned element.
Each side defaults to auto, the same as the longhands. Placement then follows other positioning rules.
In horizontal-tb writing mode it usually matches top and bottom. When writing-mode is vertical, the same rule maps to the physical left/right edges instead.
No. It only affects elements with position set to relative, absolute, fixed, or sticky.
inset always sets physical top, right, bottom, and left. inset-block only sets the logical block axis and follows writing-mode.
It is Baseline Widely available. Chrome 87+, Edge 87+, Firefox 63+, and Safari 14.1+ support it. Internet Explorer does not. It is a browser CSS property, not a Node.js feature.

Next: inset-block-end

Set only the logical block-end offset on a positioned element.

inset-block-end tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

9 people found this page helpful