CSS inset-block-start Property

The CSS inset-block-start property sets the positioning offset from the logical block-start edge of a positioned element's containing block.

Unlike the physical top, right, and left properties, inset-block-start adapts to the element's writing mode. It corresponds to the top edge in horizontal writing and the right or left edge in vertical writing, making it useful for layouts that support different writing systems.

inset-block-start Syntax

The inset-block-start property accepts a single offset value. Common values include lengths, percentages, and auto.

Basic Syntax

selector {
  inset-block-start: 20px;
}

Percentage Value

.box {
  inset-block-start: 10%;
}

Automatic Offset

.box {
  inset-block-start: auto;
}

Negative Offset

.box {
  inset-block-start: -15px;
}

Calculated Offset

.box {
  inset-block-start: calc(1rem + 10px);
}

CSS-Wide Keywords

.box {
  inset-block-start: initial;
}
.box {
  inset-block-start: inherit;
}
.box {
  inset-block-start: unset;
}
.box {
  inset-block-start: revert;
}
.box {
  inset-block-start: revert-layer;
}

The initial value is auto. The property affects the position of an element according to its position value.

Property Values

The inset-block-start property accepts the following values and expressions.

Value Description
auto Allows the applicable positioning rules to determine the offset. This is the initial value.
<length> Sets an offset using units such as px, rem, em, or viewport units.
<percentage> Sets an offset as a percentage of the corresponding containing block dimension.
calc(...) Calculates an offset using compatible CSS values.
min(...) Uses the smallest result from the supplied expressions.
max(...) Uses the largest result from the supplied expressions.
clamp(...) Constrains an offset between minimum and maximum values.
anchor(...) Uses an anchor-positioning expression where supported and permitted.
initial Resets the property to auto.
inherit Inherits the computed value from the parent element.
unset Resets the property to auto because it is not inherited.
revert Reverts the property according to cascade origin rules.
revert-layer Reverts the property according to cascade layer rules.

Property Characteristics

Characteristic Value
Initial value auto
Inherited No
Applies to Positioned elements
Computed value auto, a computed length, or a percentage
Animation type Length, percentage, or calculated value
Percentages Relative to the corresponding containing block dimension
Logical axis Block axis
Shorthand property inset-block

The physical side controlled by the property depends on the element's writing mode.

How It Works

The inset-block-start property controls the logical block-start positioning offset. Block-start is the side from which successive lines of text begin stacking.

Horizontal Writing Mode

.box {
  writing-mode: horizontal-tb;
  position: absolute;
  inset-block-start: 20px;
}

In horizontal writing mode, the property sets the top offset to 20 pixels.

Vertical Right-to-Left Writing Mode

.box {
  writing-mode: vertical-rl;
  position: absolute;
  inset-block-start: 20px;
}

In vertical right-to-left writing mode, the property sets the right offset to 20 pixels.

Vertical Left-to-Right Writing Mode

.box {
  writing-mode: vertical-lr;
  position: absolute;
  inset-block-start: 20px;
}

In vertical left-to-right writing mode, the property sets the left offset to 20 pixels.

Important Consideration

The property does not establish positioning by itself. A statically positioned element is not moved by inset-block-start.

Writing Modes

The physical side represented by inset-block-start depends on the writing-mode property.

Writing Mode Block-Start Side
horizontal-tb Top
vertical-rl Right
vertical-lr Left
sideways-rl Right
sideways-lr Left

Horizontal Writing

.horizontal {
  writing-mode: horizontal-tb;
  position: absolute;
  inset-block-start: 15px;
}

Vertical Writing

.vertical {
  writing-mode: vertical-rl;
  position: absolute;
  inset-block-start: 15px;
}

Important Consideration

Changing direction from ltr to rtl does not reverse block-start and block-end in a given writing mode. The direction property primarily affects the inline axis.

Length Values

Length values specify an offset from the logical block-start edge using absolute or relative CSS units.

Pixel Offset

.box {
  position: absolute;
  inset-block-start: 20px;
}

Root Font-Relative Offset

.box {
  position: absolute;
  inset-block-start: 2rem;
}

Viewport-Relative Offset

.box {
  position: fixed;
  inset-block-start: 5vb;
}

The vb unit represents a percentage of the viewport size along the block axis of the root element.

Important Consideration

Lengths such as px and rem specify distances, while viewport-relative units respond to viewport dimensions. Choose units that suit the intended layout.

Percentage Values

Percentage values are resolved against the relevant dimension of the containing block.

Percentage Offset

.box {
  position: absolute;
  inset-block-start: 10%;
}

Horizontal Writing Mode

.box {
  writing-mode: horizontal-tb;
  position: absolute;
  inset-block-start: 10%;
}

Because block-start maps to the top, the percentage is based on the containing block's height.

Vertical Writing Mode

.box {
  writing-mode: vertical-rl;
  position: absolute;
  inset-block-start: 10%;
}

Because block-start maps to the right, the percentage is based on the containing block's width.

Important Consideration

The same percentage can produce different physical offsets when the writing mode changes or the containing block dimensions differ.

auto Value

The auto value allows CSS positioning rules to determine the block-start offset. It is the initial value.

Automatic Offset

.box {
  position: absolute;
  inset-block-start: auto;
}

Position from Block-End

.box {
  position: absolute;
  inset-block-start: auto;
  inset-block-end: 20px;
}

This establishes a block-end offset while leaving the block-start offset automatic.

Reset an Existing Offset

.box {
  inset-block-start: auto;
}

Important Consideration

The auto value does not always produce a zero offset. Its behavior depends on the positioning mode, other offsets, and sizing constraints.

Negative Values

Negative lengths and percentages are allowed. For absolutely positioned elements, they can place content beyond the logical block-start edge of its containing block.

Negative Pixel Offset

.badge {
  position: absolute;
  inset-block-start: -10px;
}

Negative Percentage Offset

.badge {
  position: absolute;
  inset-block-start: -5%;
}

Overlapping Badge

.badge {
  position: absolute;
  inset-block-start: -12px;
  inset-inline-end: 12px;
}

This can position a badge so that it overlaps the block-start border of its container.

Important Consideration

Negative offsets can cause content to extend outside its containing block. Check overflow, clipping, and nearby content when using them.

Calculated Values

CSS math functions can calculate offsets that adapt to different dimensions or design constraints.

calc()

.box {
  position: absolute;
  inset-block-start: calc(1rem + 10px);
}

min()

.box {
  position: absolute;
  inset-block-start: min(5%, 30px);
}

max()

.box {
  position: absolute;
  inset-block-start: max(10px, 2%);
}

clamp()

.box {
  position: absolute;
  inset-block-start: clamp(10px, 3%, 40px);
}

Important Consideration

Calculated values follow the same positioning rules as ordinary lengths and percentages. They do not affect statically positioned elements.

Positioning Modes

The effect of inset-block-start depends on the element's position value.

Position Value Behavior
static The offset has no positioning effect.
relative A positive block-start offset can visually shift the element toward block-end while preserving its original layout space.
absolute The offset positions the element relative to its absolute-positioning containing block.
fixed The offset positions the element relative to its fixed-positioning containing block, usually the viewport.
sticky The offset establishes a logical block-start threshold used during sticky positioning.

Important Consideration

Absolute and fixed positioning remove elements from normal document flow. Relative and sticky positioning preserve their normal layout space.

Absolute Positioning

Absolutely positioned elements use inset-block-start to establish their offset from the logical block-start edge of the containing block.

Position a Badge

.container {
  position: relative;
}
.badge {
  position: absolute;
  inset-block-start: 10px;
  inset-inline-end: 10px;
}

In horizontal writing mode, the badge appears near the top and inline-end edges of its containing block.

Position a Panel

.panel {
  position: absolute;
  inset-block-start: 20px;
  inset-inline: 15px;
}

Important Consideration

A positioned ancestor commonly establishes the containing block for absolutely positioned descendants. Other CSS properties can also establish containing blocks.

Fixed Positioning

Fixed positioning can keep an element at a logical block-start offset relative to its fixed-positioning containing block.

Fixed Header

.fixed-header {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  block-size: 70px;
}

Fixed Notification

.notification {
  position: fixed;
  inset-block-start: 20px;
  inset-inline-end: 20px;
}

In horizontal writing mode, the notification appears near the top and inline-end edges of the viewport in a typical fixed-positioning context.

Important Consideration

Transforms and certain other ancestor properties can establish containing blocks for fixed descendants. Fixed positioning is therefore not always relative to the viewport.

Relative Positioning

For relatively positioned elements, a positive block-start offset can visually shift the element toward block-end when the opposing block-end offset is auto.

Move Toward Block-End

.box {
  position: relative;
  inset-block-start: 15px;
}

In horizontal writing mode, this moves the element downward by 15 pixels.

Move Toward Block-Start

.box {
  position: relative;
  inset-block-start: -15px;
}

In horizontal writing mode, this moves the element upward by 15 pixels.

Opposing Offsets

.box {
  position: relative;
  inset-block-start: 10px;
  inset-block-end: 20px;
}

When both opposing offsets are specified for relative positioning, CSS resolves the over-constrained axis instead of applying both shifts independently.

Important Consideration

Relative positioning preserves the element's original layout space. Other elements are laid out as though the visual shift had not occurred.

Sticky Positioning

The inset-block-start property is commonly used to establish a sticky positioning threshold at the logical block-start edge of a scroll container.

Sticky Heading

.section-heading {
  position: sticky;
  inset-block-start: 0;
}

In horizontal writing mode, this establishes a zero-pixel threshold at the top edge of the relevant scrollport.

Sticky Navigation

.sticky-nav {
  position: sticky;
  inset-block-start: 20px;
  z-index: 10;
}

Important Consideration

Sticky positioning depends on the scrolling container, available space, and containing block. A non-auto offset is needed on the relevant axis for sticky positioning to take effect on that axis.

Physical vs. Logical Offsets

The physical top property always controls the top offset. The logical inset-block-start property adapts to the writing mode.

Physical Offset

.box {
  position: absolute;
  top: 20px;
}

Logical Offset

.box {
  position: absolute;
  inset-block-start: 20px;
}

Comparison

Writing Mode top inset-block-start
horizontal-tb Top Top
vertical-rl Top Right
vertical-lr Top Left

Important Consideration

When a physical and logical offset target the same side, the cascade determines which declaration applies. Use logical offsets when the intended placement should follow the writing mode.

inset-block Shorthand

The inset-block shorthand combines inset-block-start and inset-block-end.

Longhand Declarations

.box {
  inset-block-start: 10px;
  inset-block-end: 20px;
}

Equivalent Shorthand

.box {
  inset-block: 10px 20px;
}

One Shorthand Value

.box {
  inset-block: 20px;
}

This assigns 20 pixels to both logical block offsets.

Override Block-Start

.box {
  inset-block: 10px 20px;
  inset-block-start: 30px;
}

The later longhand declaration changes the block-start offset to 30 pixels.

Important Consideration

A later inset-block shorthand can overwrite an earlier inset-block-start declaration when both have the same cascade priority.

inset-block-start and Sizing

For absolutely or fixed-positioned elements, the block-start offset can participate in determining the used position and size along the block axis.

Opposing Offsets

.panel {
  position: absolute;
  inset-block-start: 20px;
  inset-block-end: 20px;
}

With an automatic block size and no conflicting constraints, the opposing offsets can cause the element to stretch along the block axis.

Explicit Block Size

.panel {
  position: absolute;
  inset-block-start: 20px;
  block-size: 100px;
}

The element has an explicit logical block size and a defined block-start offset.

Maximum Block Size

.panel {
  position: absolute;
  inset-block-start: 20px;
  max-block-size: 300px;
  overflow: auto;
}

Important Consideration

The final position and dimensions depend on the offsets, sizing properties, margins, padding, borders, intrinsic size, and containing block.

Inheritance

The inset-block-start property is not inherited. Its initial value is auto.

Parent Offset

.parent {
  position: relative;
  inset-block-start: 20px;
}

A child does not automatically inherit the parent's offset.

Explicit Inheritance

.child {
  position: relative;
  inset-block-start: inherit;
}

Reset to Initial Value

.child {
  inset-block-start: initial;
}

This resets the property to auto.

Reset with unset

.child {
  inset-block-start: unset;
}

Because the property is not inherited, unset behaves like initial.

inset-block-start Example

This example demonstrates how the same logical block-start offset maps to different physical sides in horizontal and vertical writing modes.

HTML Example

<div class="inset-block-start-demo">
  <div class="demo-panel">
    <h3>Horizontal Writing</h3>
    <div class="demo-container horizontal">
      <div class="demo-box">Block-Start</div>
    </div>
  </div>
  <div class="demo-panel">
    <h3>Vertical Writing</h3>
    <div class="demo-container vertical">
      <div class="demo-box">Block-Start</div>
    </div>
  </div>
</div>

CSS Example

.inset-block-start-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.inset-block-start-demo .demo-panel {
  flex: 1 1 220px;
  min-width: 0;
}
.inset-block-start-demo h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.inset-block-start-demo .demo-container {
  position: relative;
  height: 180px;
  border: 2px solid #2563eb;
  background-color: #eff6ff;
}
.inset-block-start-demo .demo-box {
  position: absolute;
  inset-block-start: 20px;
  inset-inline-start: 15px;
  padding: 12px;
  border: 2px dashed #1d4ed8;
  background-color: #bfdbfe;
  color: #1e3a8a;
  font-weight: bold;
  font-size: 0.875rem;
  box-sizing: border-box;
}
.inset-block-start-demo .horizontal {
  writing-mode: horizontal-tb;
}
.inset-block-start-demo .vertical {
  writing-mode: vertical-rl;
}
Browser Result

Horizontal Writing

Block-Start

Vertical Writing

Block-Start

In horizontal writing mode, the box is positioned 20 pixels from the top edge. In vertical right-to-left writing mode, the same property positions it 20 pixels from the right edge.

Try a Larger Offset

.inset-block-start-demo .demo-box {
  inset-block-start: 40px;
}

The box moves farther from the logical block-start edge.

Try vertical-lr

.inset-block-start-demo .vertical {
  writing-mode: vertical-lr;
}

The logical block-start edge now corresponds to the left side instead of the right.

Common Mistakes

Forgetting to Set position

.box {
  inset-block-start: 20px;
}

The offset has no positioning effect when the element is statically positioned.

Using Multiple Values

.box {
  inset-block-start: 10px 20px;
}

This is invalid. The longhand property accepts a single offset value. Use inset-block to set both block offsets.

Using a Unitless Length

.box {
  inset-block-start: 20;
}

Nonzero CSS lengths require an appropriate unit.

Assuming Block-Start Always Means Top

Block-start maps to top in horizontal writing mode, but it maps to right or left in vertical writing modes.

Confusing inset-block-start with margin-block-start

The inset-block-start property controls positioning. The margin-block-start property controls logical outer spacing.

Mixing Conflicting Physical and Logical Offsets

.box {
  top: 10px;
  inset-block-start: 20px;
}

In horizontal writing mode, both declarations target the top offset. The cascade determines which value applies.

Assuming auto Means Zero

The auto value is resolved according to the applicable positioning rules and does not always produce a zero offset.

Ignoring Containing Block Dimensions

Percentage offsets depend on the corresponding containing block dimension, which may change with the physical mapping of the logical side.

Important Considerations

Keep the following points in mind when using inset-block-start:

  • The property sets the logical block-start positioning offset.
  • It accepts one offset value.
  • The initial value is auto.
  • The property is not inherited.
  • The physical side depends on the element's writing mode.
  • In horizontal-tb, block-start corresponds to top.
  • In vertical-rl, block-start corresponds to right.
  • In vertical-lr, block-start corresponds to left.
  • The position property determines how the offset is interpreted.
  • The offset has no positioning effect on statically positioned elements.
  • Absolute and fixed positioning remove elements from normal document flow.
  • Relative positioning preserves the element's original layout space.
  • Sticky positioning uses offsets as scrolling thresholds.
  • Negative length and percentage offsets are allowed.
  • Percentage offsets depend on the corresponding containing block dimension.
  • The property is a longhand of inset-block.
  • Physical and logical offsets can target the same side and interact through the cascade.
  • Use inset-block-end to control the opposite logical block edge.
  • Test positioned content for overlap, clipping, and overflow.

Browser Support

The CSS inset-block-start property is widely supported in modern browsers, including Chrome, Edge, Firefox, Safari, and Opera.

Basic length, percentage, and auto offsets are broadly supported. Newer positioning features, such as anchor positioning, may have separate compatibility requirements.

For current compatibility information, visit Can I Use? and search for inset-block-start.

Specifications

The inset-block-start property is defined in the CSS Logical Properties and Values Module Level 1 specification.

CSS Logical Properties and Values Module Level 1: Inset Properties

The specification defines logical positioning properties and their mapping to physical offsets according to writing modes.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: inset-block-start