CSS inset-inline Property

The CSS inset-inline property is a shorthand that sets the logical inline-start and inline-end positioning offsets of an element.

It combines inset-inline-start and inset-inline-end into one declaration. Unlike physical positioning properties such as left and right, these offsets adapt to the element's writing mode and text direction, making them useful for multilingual and responsive layouts.

inset-inline Syntax

The inset-inline shorthand accepts one or two values. Each value can be a length, percentage, or auto.

Basic Syntax

selector {
  inset-inline: 20px;
}

Two Values

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

Percentage Values

.box {
  inset-inline: 5% 10%;
}

Automatic Offsets

.box {
  inset-inline: auto;
}

Mixed Values

.box {
  inset-inline: 20px auto;
}

Calculated Values

.box {
  inset-inline: calc(1rem + 5px) 10%;
}

CSS-Wide Keywords

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

CSS-wide keywords must be used alone. The initial value of both longhand properties is auto.

Property Values

Each offset in inset-inline accepts the following values and expressions.

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

Property Characteristics

Characteristic Value
Initial value auto for both longhands
Inherited No
Applies to Positioned elements
Computed value As specified for each longhand property
Animation type As specified for each longhand property
Percentages Relative to the corresponding containing block dimension
Logical axis Inline axis
Longhand properties inset-inline-start, inset-inline-end

The shorthand expands into two logical positioning properties. Their physical mapping depends on the element's writing mode and direction.

How It Works

The inline axis follows the direction in which text progresses within a line. The inset-inline shorthand controls positioning offsets from both ends of that axis.

One Offset for Both Sides

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

This assigns 20 pixels to both logical inline offsets.

Different Offsets

.box {
  position: absolute;
  inset-inline: 10px 30px;
}

The first value controls inline-start, and the second controls inline-end.

Equivalent Longhand Declarations

.box {
  position: absolute;
  inset-inline-start: 10px;
  inset-inline-end: 30px;
}

Important Consideration

The shorthand does not establish positioning by itself. A statically positioned element is not moved by its offsets.

One Value vs. Two Values

The number of values determines how the two logical offsets are assigned.

Declaration Inline-Start Inline-End
inset-inline: 20px; 20px 20px
inset-inline: 10px 30px; 10px 30px
inset-inline: auto 20px; auto 20px
inset-inline: 5% 10%; 5% 10%

One Value

.box {
  inset-inline: 15px;
}

Both logical offsets receive the same value.

Two Values

.box {
  inset-inline: 15px 25px;
}

The first value sets inline-start. The second sets inline-end.

Important Consideration

The values are assigned in logical start-to-end order, not necessarily physical left-to-right order.

Writing Modes

The physical sides represented by inset-inline-start and inset-inline-end depend on the writing mode and direction.

Writing Mode Direction Inline-Start Inline-End
horizontal-tb ltr Left Right
horizontal-tb rtl Right Left
vertical-rl ltr Top Bottom
vertical-rl rtl Bottom Top
vertical-lr ltr Top Bottom
vertical-lr rtl Bottom Top

Horizontal Writing

.box {
  writing-mode: horizontal-tb;
  direction: ltr;
  position: absolute;
  inset-inline: 10px 20px;
}

Inline-start maps to left, and inline-end maps to right.

Vertical Writing

.box {
  writing-mode: vertical-rl;
  direction: ltr;
  position: absolute;
  inset-inline: 10px 20px;
}

Inline-start maps to top, and inline-end maps to bottom.

Important Consideration

The writing-mode property determines the inline axis, while direction determines which end of that axis is inline-start.

Text Direction

In horizontal writing, changing the text direction reverses the physical sides represented by inline-start and inline-end.

Left-to-Right Direction

.ltr-box {
  direction: ltr;
  position: absolute;
  inset-inline: 10px 30px;
}

With horizontal writing, the offsets correspond to 10 pixels from the left and 30 pixels from the right.

Right-to-Left Direction

.rtl-box {
  direction: rtl;
  position: absolute;
  inset-inline: 10px 30px;
}

With horizontal writing, the offsets correspond to 10 pixels from the right and 30 pixels from the left.

Important Consideration

Logical properties are especially useful when a design must support both left-to-right and right-to-left languages without separate physical positioning declarations.

Length Values

Length values specify distances from the logical inline edges using absolute or relative CSS units.

Pixel Offsets

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

Different Length Units

.box {
  position: absolute;
  inset-inline: 1rem 24px;
}

Viewport-Relative Offsets

.box {
  position: fixed;
  inset-inline: 5vi;
}

The vi unit represents a percentage of the viewport size along the inline axis of the root element.

Important Consideration

Lengths determine offset distances. The actual physical sides are still controlled by the writing mode and direction.

Percentage Values

Percentage offsets are resolved against the corresponding dimension of the containing block.

Equal Percentages

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

Different Percentages

.box {
  position: absolute;
  inset-inline: 5% 15%;
}

Horizontal Writing

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

In horizontal writing, the percentages are based on the containing block's width.

Vertical Writing

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

In vertical writing, the percentages are based on the containing block's height.

Important Consideration

Percentage offsets can change as the containing block changes size. They do not represent percentages of the positioned element's own dimensions.

auto Value

The auto value allows CSS positioning rules to determine one or both logical inline offsets.

Both Offsets Automatic

.box {
  position: absolute;
  inset-inline: auto;
}

Automatic Inline-End

.box {
  position: absolute;
  inset-inline: 20px auto;
}

The inline-start offset is 20 pixels, while the inline-end offset remains automatic.

Automatic Inline-Start

.box {
  position: absolute;
  inset-inline: auto 20px;
}

The inline-end offset is 20 pixels, while the inline-start offset remains automatic.

Important Consideration

auto does not always mean zero. The used offsets depend on positioning rules, sizing, and other constraints.

Negative Values

Negative lengths and percentages are permitted. They can place positioned content beyond the logical inline edges of its containing block.

Negative Inline-Start

.badge {
  position: absolute;
  inset-inline: -10px auto;
}

Negative Inline-End

.badge {
  position: absolute;
  inset-inline: auto -10px;
}

Both Offsets Negative

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

With automatic inline sizing and no conflicting constraints, negative offsets can extend a positioned panel beyond both inline edges.

Important Consideration

Negative offsets may cause content to overlap nearby elements or extend outside the visible area. Check overflow and clipping.

Calculated Values

CSS math functions allow inline offsets to combine fixed, relative, and percentage values.

calc()

.box {
  position: absolute;
  inset-inline: calc(1rem + 5px);
}

min()

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

max()

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

clamp()

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

Different Calculations

.box {
  position: absolute;
  inset-inline: calc(1rem + 5px) clamp(10px, 2%, 30px);
}

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-inline depends on the element's position value.

Position Value Behavior
static The offsets have no positioning effect.
relative The offsets can visually shift the element along the inline axis without changing its original layout space.
absolute The offsets position the element relative to its absolute-positioning containing block.
fixed The offsets position the element relative to its fixed-positioning containing block, usually the viewport.
sticky The offsets establish logical inline-axis thresholds 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 can use inset-inline to establish offsets from both logical inline edges of their containing block.

Position a Panel

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

With automatic inline sizing and no conflicting constraints, the panel can stretch between the two inline offsets.

Different Inline Offsets

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

Position a Badge

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

Important Consideration

The containing block is commonly established by a positioned ancestor. Other CSS properties can also establish containing blocks.

Fixed Positioning

Fixed positioning allows an element to use logical inline offsets relative to its fixed-positioning containing block.

Fixed Banner

.fixed-banner {
  position: fixed;
  inset-inline: 0;
  inset-block-start: 0;
}

With automatic inline sizing, this can create a banner that stretches across the available inline dimension.

Fixed Notification

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

This places the notification near the logical inline-end and block-end edges.

Important Consideration

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

Relative Positioning

For relatively positioned elements, inset-inline can visually shift the element along the inline axis while preserving its original layout space.

Move Toward Inline-End

.box {
  position: relative;
  inset-inline: 15px auto;
}

In horizontal left-to-right writing, this shifts the element 15 pixels to the right.

Move Toward Inline-Start

.box {
  position: relative;
  inset-inline: auto 15px;
}

In horizontal left-to-right writing, this shifts the element 15 pixels to the left.

Opposing Offsets

.box {
  position: relative;
  inset-inline: 10px 20px;
}

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

Important Consideration

Relative positioning does not change the element's original layout space. Nearby content remains laid out as though the visual shift had not occurred.

Sticky Positioning

Sticky positioning can use logical inline offsets as thresholds when scrolling occurs along the inline axis.

Sticky Inline-Start Element

.sticky-item {
  position: sticky;
  inset-inline: 0 auto;
}

This establishes a zero offset at inline-start. It can be useful in a horizontally scrolling layout.

Sticky Inline-End Element

.sticky-item {
  position: sticky;
  inset-inline: auto 10px;
}

Important Consideration

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

Physical vs. Logical Offsets

Physical positioning properties always refer to fixed physical sides. Logical positioning properties follow the writing mode and direction.

Physical Offsets

.box {
  position: absolute;
  left: 10px;
  right: 20px;
}

Logical Offsets

.box {
  position: absolute;
  inset-inline: 10px 20px;
}

Comparison

Writing Mode and Direction Inline-Start Inline-End
horizontal-tb, ltr Left Right
horizontal-tb, rtl Right Left
vertical-rl, ltr Top Bottom
vertical-rl, rtl Bottom Top

Important Consideration

When physical and logical declarations map to the same side, the cascade determines which declaration applies. Prefer a consistent logical positioning approach when supporting different writing systems.

inset-inline and Sizing

For absolutely or fixed-positioned elements, the inline offsets can participate in determining the used inline size.

Stretch Between Inline Edges

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

With automatic inline sizing and no conflicting constraints, the panel can stretch between the two offsets.

Explicit Inline Size

.panel {
  position: absolute;
  inset-inline: 20px auto;
  inline-size: 250px;
}

The panel has an explicit logical inline size and a defined inline-start offset.

Maximum Inline Size

.panel {
  position: absolute;
  inset-inline: 20px;
  max-inline-size: 400px;
}

The maximum inline size can constrain the panel even when opposing offsets would otherwise allow it to stretch farther.

Important Consideration

The final position and dimensions depend on the offsets, sizing properties, margins, borders, padding, intrinsic dimensions, and containing block. When all relevant values are definite, over-constrained positioning rules may apply.

inset Shorthand

The inset shorthand sets all four physical positioning offsets. The inset-inline shorthand sets only the two logical inline offsets.

Logical Inline Offsets

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

Physical Offsets

.box {
  inset: 10px 20px 30px 40px;
}

The four inset values correspond to top, right, bottom, and left.

Combine Logical Axes

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

This sets logical offsets along both the block and inline axes.

Override One Inline Offset

.box {
  inset-inline: 10px 20px;
  inset-inline-end: 30px;
}

The later longhand declaration changes inline-end to 30 pixels.

Important Consideration

The physical inset shorthand and logical inset-inline shorthand can target the same physical offsets. The cascade determines which declarations apply.

Inheritance

The inset-inline shorthand is not inherited. Both of its longhand properties have an initial value of auto.

Parent Offsets

.parent {
  position: relative;
  inset-inline: 10px 20px;
}

Child elements do not automatically inherit these offsets.

Explicit Inheritance

.child {
  position: relative;
  inset-inline: inherit;
}

This inherits the parent's computed inline-start and inline-end offsets.

Reset to Initial Values

.child {
  inset-inline: initial;
}

Both longhand properties return to auto.

Reset with unset

.child {
  inset-inline: unset;
}

Because neither longhand is inherited, unset behaves like initial.

inset-inline Example

This example demonstrates how the same inset-inline declaration adapts to left-to-right and right-to-left text directions.

HTML Example

<div class="inset-inline-demo">
  <div class="demo-panel">
    <h3>Left-to-Right</h3>
    <div class="demo-container ltr">
      <div class="demo-box">Positioned Box</div>
    </div>
  </div>
  <div class="demo-panel">
    <h3>Right-to-Left</h3>
    <div class="demo-container rtl">
      <div class="demo-box">Positioned Box</div>
    </div>
  </div>
</div>

CSS Example

.inset-inline-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}
.inset-inline-demo .demo-panel {
  flex: 1 1 220px;
  min-width: 0;
}
.inset-inline-demo h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}
.inset-inline-demo .demo-container {
  position: relative;
  height: 140px;
  border: 2px solid #2563eb;
  background-color: #eff6ff;
}
.inset-inline-demo .demo-box {
  position: absolute;
  inset-inline: 15px 35px;
  inset-block-start: 30px;
  padding: 12px;
  border: 2px dashed #1d4ed8;
  background-color: #bfdbfe;
  color: #1e3a8a;
  font-weight: bold;
  font-size: 0.875rem;
  box-sizing: border-box;
  text-align: center;
}
.inset-inline-demo .ltr {
  direction: ltr;
}
.inset-inline-demo .rtl {
  direction: rtl;
}
Browser Result

Left-to-Right

Positioned Box

Right-to-Left

Positioned Box

In the left-to-right container, the box has a 15-pixel left offset and a 35-pixel right offset. In the right-to-left container, those physical offsets are reversed.

Try Equal Offsets

.inset-inline-demo .demo-box {
  inset-inline: 20px;
}

Both logical inline edges now receive the same offset.

Try One Automatic Offset

.inset-inline-demo .demo-box {
  inset-inline: 15px auto;
}

The inline-start offset remains defined, while inline-end becomes automatic. The box's used inline size and position are resolved according to absolute-positioning rules.

Common Mistakes

Forgetting to Set position

.box {
  inset-inline: 20px;
}

The offsets have no positioning effect when the element is statically positioned.

Using Three Values

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

This is invalid. The shorthand accepts one or two values.

Using a Unitless Length

.box {
  inset-inline: 20;
}

Nonzero CSS lengths require an appropriate unit.

Assuming Inline-Start Always Means Left

Inline-start maps to left in horizontal left-to-right writing, but it can map to right, top, or bottom in other writing modes and directions.

Confusing inset-inline with margin-inline

The inset-inline property controls positioning offsets. The margin-inline property controls logical outer spacing.

Assuming Both Offsets Always Stretch an Element

Opposing offsets can contribute to automatic sizing for absolutely positioned elements, but explicit dimensions and other constraints may prevent stretching.

Mixing Physical and Logical Offsets

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

In horizontal left-to-right writing, both declarations target the left offset. The cascade determines which applies.

Assuming auto Means Zero

Automatic offsets are resolved according to positioning rules and do not always equal zero.

Important Considerations

Keep the following points in mind when using inset-inline:

  • The property is a shorthand for inset-inline-start and inset-inline-end.
  • It accepts one or two values.
  • One value applies to both logical inline offsets.
  • With two values, the first controls inline-start and the second controls inline-end.
  • The initial value of both longhands is auto.
  • The property is not inherited.
  • The physical sides depend on writing mode and direction.
  • In horizontal left-to-right writing, inline-start is left and inline-end is right.
  • In horizontal right-to-left writing, inline-start is right and inline-end is left.
  • In vertical writing, the inline offsets generally map to top and bottom, with their order determined by direction.
  • The position property determines how the offsets are interpreted.
  • The offsets have 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 lengths and percentages are permitted.
  • Percentage offsets depend on the corresponding containing block dimension.
  • Opposing offsets can influence the automatic inline size of absolutely positioned elements.
  • Physical and logical offsets can target the same sides and interact through the cascade.
  • Test positioned content for overlap, clipping, and overflow.

Browser Support

The CSS inset-inline 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-inline.

Specifications

The inset-inline 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 and text direction.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: inset-inline