CSS inset-block Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Positioning

What You’ll Learn

The inset-block property sets offsets along the block axis using logical CSS. It is the block-axis counterpart to physical top and bottom properties.

01

Block Axis

Logical offset.

02

auto

Default value.

03

Shorthand

Start & end.

04

Writing Mode

Adapts axis.

05

absolute

Common use.

06

inset

Related set.

Introduction

The inset-block property in CSS is part of the Logical Properties and Values specification. It lets you control the block-start and block-end offsets of a positioned element in one declaration.

This is especially useful for layouts that must adapt to different writing modes, such as left-to-right, right-to-left, and vertical text directions.

Definition and Usage

Apply inset-block on positioned elements when you want to offset them along the block axis. In normal horizontal English pages, that usually means top and bottom offsets.

💡
Beginner Tip

Think of inset-block as logical top + bottom. Pair it with inset-inline for full logical positioning.

📝 Syntax

The syntax for the inset-block property accepts one or two values:

syntax.css
element {
  inset-block: value;
}

element {
  inset-block: block-start block-end;
}
  • One value — applies to both block-start and block-end.
  • Two values — first value is block-start; second is block-end.

Basic Example

inset-block-basic.css
.box {
  position: absolute;
  inset-block: 10px 20px;
  inline-size: 100px;
}
inset-block: auto; inset-block: 1rem; inset-block: 10px 20px; inset-block: 0;

Default Value

The default value of the inset-block property is auto, which means the browser determines block-axis placement from other positioning rules.

Syntax Rules

  • Shorthand for inset-block-start and inset-block-end.
  • Only works when position is not static.
  • The property is not inherited.
  • Accepts length, percentage, and auto values.
  • In horizontal writing mode, maps to top and bottom.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toPositioned elements
InheritedNo
AnimatableYes, as a length
Horizontal writing modeBehaves like top and bottom

💎 Property Values

ValueDescription
lengthA fixed offset such as 20px, 1em, or 1rem.
percentageAn offset relative to the containing block size on the block axis.
autoLets the browser calculate the offset automatically.

Block Axis and Writing Modes

Logical inset properties follow the document’s writing mode instead of fixed physical directions:

  • Horizontal mode (writing-mode: horizontal-tb) — block axis is vertical; inset-block controls top and bottom offsets.
  • Vertical mode (writing-mode: vertical-rl) — block axis rotates; the same property controls the logical block direction.
  • Related shorthandinset-inline handles the inline axis, and inset sets all four sides together.
🔄
Logical Positioning Set

Use inset-block + inset-inline together for writing-mode-aware layouts, or inset when you want all offsets in one rule.

👀 Live Preview

An absolutely positioned box with inset-block: 10px 20px in horizontal writing mode:

Examples Gallery

Set two block offsets, stretch with inset-block: 0, use a single value, and see behavior in vertical writing mode.

🔢 Block-Axis Offsets

Start with the reference example — separate block-start and block-end offsets.

Example 1 — Two-Value inset-block

Set block-start to 10px and block-end to 20px on an absolutely positioned box.

inset-block-two.css
.box {
  position: absolute;
  inset-block: 10px 20px;
  inline-size: 100px;
}
Try It Yourself

How It Works

In horizontal writing mode, the box sits 10px from the top and 20px from the bottom of its container.

Example 2 — Stretch with inset-block: 0

Stretch an element fully along the block axis inside a positioned container.

inset-block-zero.css
.sidebar {
  position: absolute;
  inset-block: 0;
  inset-inline-start: 0;
  inline-size: 4rem;
}
Try It Yourself

How It Works

inset-block: 0 pins both block edges to the container, creating a full-height sidebar strip.

📈 Single Value & Writing Modes

Use one value for equal offsets and test logical behavior in vertical writing mode.

Example 3 — Single-Value inset-block

Apply the same offset to both block-start and block-end with one value.

inset-block-one.css
.box {
  position: absolute;
  inset-block: 1rem;
  inset-inline: 2rem;
}
Try It Yourself

How It Works

One value applies to both block edges. Combined with inset-inline, you get even spacing on all logical sides.

Example 4 — Vertical Writing Mode

See how inset-block still controls block-axis offsets when text flows vertically.

inset-block-vertical.css
.container {
  writing-mode: vertical-rl;
  position: relative;
}

.box {
  position: absolute;
  inset-block: 12px 24px;
}
Try It Yourself

How It Works

Logical properties follow the block axis, not fixed top and bottom directions, so the same rule works across writing modes.

♿ Accessibility

  • Positioning does not change reading order — DOM order still matters for screen readers.
  • Test vertical and RTL layouts — Logical offsets should not hide essential content.
  • Avoid covering focusable controls — Absolutely positioned panels can block keyboard access.
  • Support zoom on mobile — Fixed block offsets should not clip important text.
  • Announce overlays properly — Use appropriate ARIA roles for modal and toast UI.

🧠 How inset-block Works

1

Writing mode defines the block axis

Horizontal or vertical text flow determines which physical direction block-start and block-end map to.

Writing mode
2

inset-block sets two offsets

One declaration controls both block-start and block-end distances for a positioned element.

CSS rule
3

The browser places the element

The box is offset from the containing block along the block axis.

Layout
=

Logical block positioning

Layouts adapt cleanly when writing direction or mode changes.

🖥 Browser Compatibility

The inset-block property is supported in modern browsers including Chrome 87+, Firefox 63+, Safari 14.1+, and Edge 87+.

Baseline · Modern browsers

Logical positioning in today’s browsers

All major browsers support inset-block as part of the CSS Logical Properties module.

94% Modern browser support
Google Chrome 87+ · Desktop & Mobile
Full support
Mozilla Firefox 63+ · Desktop & Mobile
Full support
Apple Safari 14.1+ · macOS & iOS
Full support
Microsoft Edge 87+ · Chromium
Full support
Opera 73+ · Modern versions
Full support
inset-block property 94% supported

Bottom line: Safe for modern logical layouts. Use physical top and bottom only when legacy support is required.

🎉 Conclusion

The inset-block property is a versatile tool for managing block-axis positioning in a writing-mode-aware way. It simplifies logical layouts and pairs naturally with other logical inset and sizing properties.

For beginners, start with horizontal pages where it behaves like top and bottom, then explore vertical writing modes to see the real advantage of logical CSS.

💡 Best Practices

✅ Do

  • Use with logical sizing properties like inline-size
  • Pair with inset-inline for full logical placement
  • Test in RTL and vertical writing modes
  • Use inset-block: 0 for full block-axis stretch
  • Set a non-static position value first

❌ Don’t

  • Apply without positioning context
  • Mix logical and physical offsets without reason
  • Assume it works like margin or padding
  • Hide critical content with absolute overlays
  • Forget containing block setup for absolute children

Key Takeaways

Knowledge Unlocked

Five things to remember about inset-block

Use these points when building logical positioned layouts.

5
Core concepts
auto 02

Default auto

Browser pick.

Default
2 vals 03

Start & end

Shorthand.

Syntax
mode 04

Writing mode

Adapts axis.

Pattern
inset 05

Related

Logical set.

Family

❓ Frequently Asked Questions

inset-block is a logical shorthand that sets inset-block-start and inset-block-end offsets along the block axis of an element.
The default is auto, which lets the browser determine block-axis placement from other positioning rules.
In horizontal writing mode they often match top and bottom, but inset-block follows the block axis and adapts when writing mode changes.
No. Like inset, it only affects elements with position set to relative, absolute, fixed, or sticky.
No. inset-block is not inherited.

Practice in the Live Editor

Open the HTML editor, combine inset-block with logical sizing, and compare horizontal versus vertical writing modes.

HTML Editor →

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.

5 people found this page helpful