CSS inset-inline-end Property
The CSS inset-inline-end property sets the positioning offset from the logical inline-end edge of a positioned element's containing block.
Unlike the physical right and left properties, inset-inline-end adapts to the element's writing mode and text direction. It is useful for positioning badges, buttons, panels, and other interface elements in layouts that support different writing systems.
inset-inline-end Syntax
The inset-inline-end property accepts a single offset value. Common values include lengths, percentages, and auto.
Basic Syntax
selector {
inset-inline-end: 20px;
}
Percentage Value
.box {
inset-inline-end: 10%;
}
Automatic Offset
.box {
inset-inline-end: auto;
}
Negative Offset
.box {
inset-inline-end: -15px;
}
Calculated Offset
.box {
inset-inline-end: calc(1rem + 10px);
}
CSS-Wide Keywords
.box {
inset-inline-end: initial;
}
.box {
inset-inline-end: inherit;
}
.box {
inset-inline-end: unset;
}
.box {
inset-inline-end: revert;
}
.box {
inset-inline-end: revert-layer;
}
The initial value is auto. The offset affects the element according to its position value.
Property Values
The inset-inline-end 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 | Inline axis |
| Shorthand property | inset-inline |
The physical side controlled by the property depends on the element's writing mode and direction.
How It Works
The inset-inline-end property controls the logical inline-end positioning offset. Inline-end is the side where text progression ends within a line.
Horizontal Left-to-Right Writing
.box {
writing-mode: horizontal-tb;
direction: ltr;
position: absolute;
inset-inline-end: 20px;
}
In horizontal left-to-right writing, inline-end corresponds to the right edge.
Horizontal Right-to-Left Writing
.box {
writing-mode: horizontal-tb;
direction: rtl;
position: absolute;
inset-inline-end: 20px;
}
In horizontal right-to-left writing, inline-end corresponds to the left edge.
Vertical Writing
.box {
writing-mode: vertical-rl;
direction: ltr;
position: absolute;
inset-inline-end: 20px;
}
In vertical writing with left-to-right direction, inline-end corresponds to the bottom edge.
Important Consideration
The property does not establish positioning by itself. A statically positioned element is not moved by inset-inline-end.
Writing Modes
The physical side represented by inset-inline-end depends on the writing-mode and direction properties.
| Writing Mode | Direction | Inline-End Side |
|---|---|---|
horizontal-tb |
ltr |
Right |
horizontal-tb |
rtl |
Left |
vertical-rl |
ltr |
Bottom |
vertical-rl |
rtl |
Top |
vertical-lr |
ltr |
Bottom |
vertical-lr |
rtl |
Top |
sideways-rl |
ltr |
Bottom |
sideways-lr |
ltr |
Top |
Horizontal Writing
.horizontal {
writing-mode: horizontal-tb;
direction: ltr;
position: absolute;
inset-inline-end: 15px;
}
Vertical Writing
.vertical {
writing-mode: vertical-rl;
direction: ltr;
position: absolute;
inset-inline-end: 15px;
}
Important Consideration
The writing-mode property establishes the inline axis, while direction determines which end is inline-start and which is inline-end.
Text Direction
In horizontal writing, changing the text direction reverses the physical side represented by inset-inline-end.
Left-to-Right Direction
.ltr-box {
direction: ltr;
position: absolute;
inset-inline-end: 20px;
}
With horizontal writing, the element is positioned using a 20-pixel right offset.
Right-to-Left Direction
.rtl-box {
direction: rtl;
position: absolute;
inset-inline-end: 20px;
}
With horizontal writing, the element is positioned using a 20-pixel left offset.
Important Consideration
Logical offsets allow layouts to adapt to different text directions without maintaining separate left and right positioning rules.
Length Values
Length values specify an offset from the logical inline-end edge using absolute or relative CSS units.
Pixel Offset
.box {
position: absolute;
inset-inline-end: 20px;
}
Root Font-Relative Offset
.box {
position: absolute;
inset-inline-end: 2rem;
}
Viewport-Relative Offset
.box {
position: fixed;
inset-inline-end: 5vi;
}
The vi unit represents a percentage of the viewport size along the inline axis of the root element.
Important Consideration
The selected unit determines the offset distance. The writing mode and direction determine the physical edge from which that distance is measured.
Percentage Values
Percentage values are resolved against the corresponding dimension of the containing block.
Percentage Offset
.box {
position: absolute;
inset-inline-end: 10%;
}
Horizontal Writing Mode
.box {
writing-mode: horizontal-tb;
position: absolute;
inset-inline-end: 10%;
}
In horizontal writing, inline-end maps to a left or right offset, so the percentage is based on the containing block's width.
Vertical Writing Mode
.box {
writing-mode: vertical-rl;
position: absolute;
inset-inline-end: 10%;
}
In vertical writing, inline-end maps to a top or bottom offset, so the percentage is based on the containing block's height.
Important Consideration
Percentage offsets are not percentages of the positioned element's own dimensions. Their used values depend on the containing block and applicable positioning rules.
auto Value
The auto value allows CSS positioning rules to determine the logical inline-end offset. It is the initial value.
Automatic Offset
.box {
position: absolute;
inset-inline-end: auto;
}
Position from Inline-Start
.box {
position: absolute;
inset-inline-start: 20px;
inset-inline-end: auto;
}
This establishes a 20-pixel inline-start offset while leaving inline-end automatic.
Reset an Existing Offset
.box {
inset-inline-end: 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 permitted. For absolutely positioned elements, they can place content beyond the logical inline-end edge of the containing block.
Negative Pixel Offset
.badge {
position: absolute;
inset-inline-end: -10px;
}
Negative Percentage Offset
.badge {
position: absolute;
inset-inline-end: -5%;
}
Overlapping Badge
.badge {
position: absolute;
inset-inline-end: -12px;
inset-block-start: 12px;
}
This can position a badge so that it overlaps the inline-end border of its container.
Important Consideration
Negative offsets can cause content to extend outside its containing block. Check for clipping, overflow, and unintended overlap.
Calculated Values
CSS math functions can calculate logical inline-end offsets that adapt to different dimensions and layout requirements.
calc()
.box {
position: absolute;
inset-inline-end: calc(1rem + 10px);
}
min()
.box {
position: absolute;
inset-inline-end: min(5%, 30px);
}
max()
.box {
position: absolute;
inset-inline-end: max(10px, 2%);
}
clamp()
.box {
position: absolute;
inset-inline-end: 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-inline-end depends on the element's position value.
| Position Value | Behavior |
|---|---|
static |
The offset has no positioning effect. |
relative |
A positive inline-end offset can visually shift the element toward inline-start 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 inline-end threshold used during sticky positioning. |
Important Consideration
Absolute and fixed positioning remove elements from normal document flow. Relative and sticky positioning preserve their original layout space.
Absolute Positioning
Absolutely positioned elements use inset-inline-end to establish an offset from the logical inline-end edge of their containing block.
Position a Badge
.container {
position: relative;
}
.badge {
position: absolute;
inset-inline-end: 10px;
inset-block-start: 10px;
}
In horizontal left-to-right writing, the badge appears near the top-right corner of its containing block.
Position a Panel
.panel {
position: absolute;
inset-inline-end: 20px;
inset-block-start: 20px;
inline-size: 200px;
}
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 inline-end offset relative to its fixed-positioning containing block.
Fixed Notification
.notification {
position: fixed;
inset-inline-end: 20px;
inset-block-end: 20px;
}
In horizontal left-to-right writing, this places the notification near the bottom-right corner of the viewport in a typical fixed-positioning context.
Fixed Side Control
.side-control {
position: fixed;
inset-inline-end: 0;
inset-block-start: 50%;
}
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 inline-end offset can visually shift the element toward inline-start when the opposing inline-start offset is auto.
Move Toward Inline-Start
.box {
position: relative;
inset-inline-end: 15px;
}
In horizontal left-to-right writing, this moves the element 15 pixels to the left.
Move Toward Inline-End
.box {
position: relative;
inset-inline-end: -15px;
}
In horizontal left-to-right writing, this moves the element 15 pixels to the right.
Opposing Offsets
.box {
position: relative;
inset-inline-start: 10px;
inset-inline-end: 20px;
}
When both opposing offsets are specified for relative positioning, CSS resolves the over-constrained axis rather than applying both shifts independently.
Important Consideration
Relative positioning preserves the element's original layout space. Nearby content is laid out as though the visual shift had not occurred.
Sticky Positioning
The inset-inline-end property can establish a sticky positioning threshold at the logical inline-end edge of a scroll container.
Sticky Inline-End Element
.sticky-item {
position: sticky;
inset-inline-end: 0;
}
In horizontal left-to-right writing, this establishes a zero-pixel threshold at the right edge of the relevant scrollport.
Sticky Inline-End Offset
.sticky-item {
position: sticky;
inset-inline-end: 20px;
z-index: 10;
}
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 adapt to writing mode and direction.
Physical Right Offset
.box {
position: absolute;
right: 20px;
}
Logical Inline-End Offset
.box {
position: absolute;
inset-inline-end: 20px;
}
Comparison
| Writing Mode and Direction | right | inset-inline-end |
|---|---|---|
horizontal-tb, ltr |
Right | Right |
horizontal-tb, rtl |
Right | Left |
vertical-rl, ltr |
Right | Bottom |
vertical-rl, rtl |
Right | Top |
Important Consideration
When a physical and logical offset target the same side, the cascade determines which declaration applies. Use logical offsets when placement should follow the writing system.
inset-inline Shorthand
The inset-inline shorthand combines inset-inline-start and inset-inline-end.
Longhand Declarations
.box {
inset-inline-start: 10px;
inset-inline-end: 20px;
}
Equivalent Shorthand
.box {
inset-inline: 10px 20px;
}
One Shorthand Value
.box {
inset-inline: 20px;
}
This assigns 20 pixels to both logical inline offsets.
Override Inline-End
.box {
inset-inline: 10px 20px;
inset-inline-end: 30px;
}
The later longhand declaration changes inline-end to 30 pixels.
Important Consideration
A later inset-inline shorthand can overwrite an earlier inset-inline-end declaration when both have the same cascade priority.
inset-inline-end and Sizing
For absolutely or fixed-positioned elements, the inline-end offset can participate in determining the used position and size along the inline axis.
Opposing Offsets
.panel {
position: absolute;
inset-inline-start: 20px;
inset-inline-end: 20px;
}
With an automatic inline size and no conflicting constraints, opposing offsets can cause the panel to stretch along the inline axis.
Explicit Inline Size
.panel {
position: absolute;
inset-inline-end: 20px;
inline-size: 200px;
}
The panel has an explicit logical inline size and a defined inline-end offset.
Maximum Inline Size
.panel {
position: absolute;
inset-inline-end: 20px;
max-inline-size: 300px;
}
Important Consideration
The final position and dimensions depend on offsets, sizing properties, margins, padding, borders, intrinsic size, and the containing block.
Inheritance
The inset-inline-end property is not inherited. Its initial value is auto.
Parent Offset
.parent {
position: relative;
inset-inline-end: 20px;
}
A child does not automatically inherit the parent's offset.
Explicit Inheritance
.child {
position: relative;
inset-inline-end: inherit;
}
Reset to Initial Value
.child {
inset-inline-end: initial;
}
This resets the property to auto.
Reset with unset
.child {
inset-inline-end: unset;
}
Because the property is not inherited, unset behaves like initial.
inset-inline-end Example
This example demonstrates how the same logical inline-end offset maps to different physical sides in left-to-right and right-to-left layouts.
HTML Example
<div class="inset-inline-end-demo">
<div class="demo-panel">
<h3>Left-to-Right</h3>
<div class="demo-container ltr">
<div class="demo-box">Inline-End</div>
</div>
</div>
<div class="demo-panel">
<h3>Right-to-Left</h3>
<div class="demo-container rtl">
<div class="demo-box">Inline-End</div>
</div>
</div>
</div>
CSS Example
.inset-inline-end-demo {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.inset-inline-end-demo .demo-panel {
flex: 1 1 220px;
min-width: 0;
}
.inset-inline-end-demo h3 {
margin: 0 0 12px;
font-size: 1rem;
}
.inset-inline-end-demo .demo-container {
position: relative;
height: 150px;
border: 2px solid #2563eb;
background-color: #eff6ff;
}
.inset-inline-end-demo .demo-box {
position: absolute;
inset-inline-end: 20px;
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;
}
.inset-inline-end-demo .ltr {
direction: ltr;
}
.inset-inline-end-demo .rtl {
direction: rtl;
}
Left-to-Right
Right-to-Left
In the left-to-right container, the box is positioned 20 pixels from the right edge. In the right-to-left container, the same declaration positions it 20 pixels from the left edge.
Try a Larger Offset
.inset-inline-end-demo .demo-box {
inset-inline-end: 40px;
}
The box moves farther from the logical inline-end edge.
Try a Negative Offset
.inset-inline-end-demo .demo-box {
inset-inline-end: -10px;
}
The box extends beyond the logical inline-end edge of its container.
Common Mistakes
Forgetting to Set position
.box {
inset-inline-end: 20px;
}
The offset has no positioning effect when the element is statically positioned.
Using Multiple Values
.box {
inset-inline-end: 10px 20px;
}
This is invalid. The longhand property accepts a single offset value. Use inset-inline to set both inline offsets.
Using a Unitless Length
.box {
inset-inline-end: 20;
}
Nonzero CSS lengths require an appropriate unit.
Assuming Inline-End Always Means Right
Inline-end maps to right in horizontal left-to-right writing, but it can map to left, top, or bottom in other writing modes and directions.
Confusing inset-inline-end with margin-inline-end
The inset-inline-end property controls positioning. The margin-inline-end property controls logical outer spacing.
Mixing Conflicting Physical and Logical Offsets
.box {
right: 10px;
inset-inline-end: 20px;
}
In horizontal left-to-right writing, both declarations target the right offset. The cascade determines which value applies.
Assuming auto Means Zero
The auto value is resolved according to 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 when the logical side maps to a different physical axis.
Important Considerations
Keep the following points in mind when using inset-inline-end:
- The property sets the logical inline-end positioning offset.
- It accepts one offset value.
- The initial value is
auto. - The property is not inherited.
- The physical side depends on writing mode and direction.
- In horizontal left-to-right writing, inline-end corresponds to right.
- In horizontal right-to-left writing, inline-end corresponds to left.
- In vertical writing, inline-end commonly corresponds to top or bottom, depending on direction.
- The
positionproperty 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 lengths and percentages are permitted.
- Percentage offsets depend on the corresponding containing block dimension.
- The property is a longhand of
inset-inline. - Physical and logical offsets can target the same side and interact through the cascade.
- Use
inset-inline-startto control the opposite logical inline edge. - Test positioned content for overlap, clipping, and overflow.
Browser Support
The CSS inset-inline-end 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-end.
Specifications
The inset-inline-end 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.
