CSS inset-block-end Property
The CSS inset-block-end property sets the positioning offset between an element and the logical block-end edge of its containing block.
The physical side controlled by this property depends on the element's writing mode. In horizontal writing, block-end corresponds to the bottom edge. In vertical writing, it corresponds to either the left or right edge. This allows positioned elements to adapt to different writing systems without changing their CSS offsets.
inset-block-end Syntax
The inset-block-end property accepts a single positioning offset. Common values include lengths, percentages, and auto.
Basic Syntax
selector {
inset-block-end: 20px;
}
Percentage Value
.box {
inset-block-end: 10%;
}
Automatic Offset
.box {
inset-block-end: auto;
}
Negative Offset
.box {
inset-block-end: -15px;
}
Calculated Offset
.box {
inset-block-end: calc(1rem + 10px);
}
CSS-Wide Keywords
.box {
inset-block-end: initial;
}
.box {
inset-block-end: inherit;
}
.box {
inset-block-end: unset;
}
.box {
inset-block-end: revert;
}
.box {
inset-block-end: revert-layer;
}
The initial value is auto. The property affects positioning only when the element uses an appropriate position value.
Property Values
The inset-block-end property accepts the following values and expressions.
| Value | Description |
|---|---|
auto |
Allows the applicable positioning rules to determine the block-end 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 relevant containing block dimension. |
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 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 property's physical mapping depends on the element's writing mode.
How It Works
The inset-block-end property controls the logical block-end positioning offset. The block-end side is the edge toward which successive lines of text progress.
Horizontal Writing Mode
.box {
writing-mode: horizontal-tb;
position: absolute;
inset-block-end: 20px;
}
In horizontal writing mode, this sets the bottom offset to 20 pixels.
Vertical Right-to-Left Writing Mode
.box {
writing-mode: vertical-rl;
position: absolute;
inset-block-end: 20px;
}
In vertical right-to-left writing mode, this sets the left offset to 20 pixels.
Vertical Left-to-Right Writing Mode
.box {
writing-mode: vertical-lr;
position: absolute;
inset-block-end: 20px;
}
In vertical left-to-right writing mode, this sets the right offset to 20 pixels.
Important Consideration
The property does not establish a positioning mode by itself. A statically positioned element is not moved by inset-block-end.
Writing Modes
The physical side represented by inset-block-end depends on the writing-mode property.
| Writing Mode | Block-End Side |
|---|---|
horizontal-tb |
Bottom |
vertical-rl |
Left |
vertical-lr |
Right |
sideways-rl |
Left |
sideways-lr |
Right |
Horizontal Writing
.horizontal {
writing-mode: horizontal-tb;
inset-block-end: 15px;
}
Vertical Writing
.vertical {
writing-mode: vertical-rl;
inset-block-end: 15px;
}
Important Consideration
The direction property does not reverse the block-end side in a given writing mode. It primarily affects the inline direction.
Length Values
Length values specify a fixed or relative offset from the logical block-end edge.
Pixel Offset
.box {
position: absolute;
inset-block-end: 20px;
}
Relative Font Unit
.box {
position: absolute;
inset-block-end: 2rem;
}
Viewport Unit
.box {
position: fixed;
inset-block-end: 5vh;
}
Important Consideration
Viewport units are based on viewport dimensions, not the logical block axis. For writing-mode-aware viewport sizing, consider logical viewport units such as vb where appropriate.
Percentage Values
Percentage offsets are calculated relative to the relevant dimension of the containing block.
Percentage Offset
.box {
position: absolute;
inset-block-end: 10%;
}
Horizontal Writing Mode
.box {
writing-mode: horizontal-tb;
position: absolute;
inset-block-end: 10%;
}
Because block-end maps to the bottom, the percentage is based on the containing block's height.
Vertical Writing Mode
.box {
writing-mode: vertical-rl;
position: absolute;
inset-block-end: 10%;
}
Because block-end maps to the left, the percentage is based on the containing block's width.
Important Consideration
The same percentage may produce different physical offsets when the writing mode changes.
auto Value
The auto value allows the applicable positioning rules to determine the block-end offset.
Automatic Offset
.box {
position: absolute;
inset-block-end: auto;
}
Use the Opposite Offset
.box {
position: absolute;
inset-block-start: 20px;
inset-block-end: auto;
}
This establishes a block-start offset while leaving the block-end offset automatic.
Reset an Existing Offset
.box {
inset-block-end: auto;
}
Important Consideration
auto does not always mean zero. Its used behavior depends on the positioning mode, other offsets, and sizing constraints.
Negative Values
Negative length and percentage values are allowed. They can position an element beyond the logical block-end edge of its containing block.
Negative Pixel Offset
.badge {
position: absolute;
inset-block-end: -10px;
}
Negative Percentage Offset
.badge {
position: absolute;
inset-block-end: -5%;
}
Decorative Element
.decoration {
position: absolute;
inset-block-end: -20px;
inset-inline-end: -20px;
}
Important Consideration
Negative offsets can cause content to extend outside its container or viewport. Check overflow and clipping when using them.
Calculated Values
CSS math functions can calculate responsive or constrained block-end offsets.
calc()
.box {
position: absolute;
inset-block-end: calc(1rem + 10px);
}
min()
.box {
position: absolute;
inset-block-end: min(5%, 30px);
}
max()
.box {
position: absolute;
inset-block-end: max(10px, 2%);
}
clamp()
.box {
position: absolute;
inset-block-end: clamp(10px, 3%, 40px);
}
Important Consideration
Calculated offsets are still subject to the element's positioning mode and containing block. A valid calculated value does not affect a statically positioned element.
Positioning Modes
The effect of inset-block-end depends on the element's position value.
| Position Value | Behavior |
|---|---|
static |
The offset has no positioning effect. |
relative |
The offset can visually shift the element toward block-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 block-end 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 can use inset-block-end to position themselves relative to the logical block-end edge of their containing block.
Position a Badge
.container {
position: relative;
}
.badge {
position: absolute;
inset-block-end: 10px;
inset-inline-end: 10px;
}
In horizontal writing mode, this places the badge near the bottom and inline-end edges of the containing block.
Position a Panel
.panel {
position: absolute;
inset-block-end: 20px;
inset-inline: 15px;
}
Important Consideration
An absolutely positioned element commonly uses a positioned ancestor as its containing block. Other properties can also establish containing blocks.
Fixed Positioning
Fixed positioning allows an element to remain at a logical block-end offset relative to its fixed-positioning containing block.
Fixed Notification
.notification {
position: fixed;
inset-block-end: 20px;
inset-inline-end: 20px;
}
In horizontal writing mode, this places the notification near the bottom and inline-end edges of the viewport in a typical fixed-positioning context.
Fixed Control
.floating-control {
position: fixed;
inset-block-end: 2rem;
inset-inline-end: 2rem;
}
Important Consideration
Certain ancestor properties, including transforms, can establish a containing block for fixed descendants. Fixed positioning is therefore not always relative to the viewport.
Relative Positioning
For relatively positioned elements, a positive block-end offset can visually shift the element toward block-start when the opposing block-start offset is auto.
Move Toward Block-Start
.box {
position: relative;
inset-block-end: 15px;
}
In horizontal writing mode, this moves the element upward by 15 pixels.
Negative Relative Offset
.box {
position: relative;
inset-block-end: -15px;
}
In horizontal writing mode, this moves the element downward 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 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
Sticky positioning uses offsets as thresholds that constrain an element while scrolling.
Sticky Block-End Element
.sticky-footer {
position: sticky;
inset-block-end: 0;
}
In horizontal writing mode, this establishes a zero-pixel threshold at the bottom edge of the relevant scrollport.
Sticky Element with Spacing
.sticky-panel {
position: sticky;
inset-block-end: 20px;
}
Important Consideration
Sticky positioning depends on the scroll 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. A block-end threshold alone does not guarantee that an element will visibly stick during scrolling.
Physical vs. Logical Offsets
The bottom property always controls the physical bottom offset. The inset-block-end property controls the logical block-end offset.
Physical Offset
.box {
position: absolute;
bottom: 20px;
}
Logical Offset
.box {
position: absolute;
inset-block-end: 20px;
}
Comparison
| Writing Mode | bottom | inset-block-end |
|---|---|---|
horizontal-tb |
Bottom | Bottom |
vertical-rl |
Bottom | Left |
vertical-lr |
Bottom | Right |
Important Consideration
When physical and logical declarations map to the same side, the cascade determines which value applies. Use logical offsets when the intended position should follow the writing mode.
inset-block Shorthand
The inset-block shorthand sets both logical block-start and block-end offsets.
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 One Side
.box {
inset-block: 10px 20px;
inset-block-end: 30px;
}
The later longhand declaration changes the block-end offset to 30 pixels.
Important Consideration
A later inset-block shorthand can overwrite an earlier inset-block-end declaration when both have the same cascade priority.
inset-block-end and Sizing
For absolutely or fixed-positioned elements, the block-end offset can participate in determining the used position and size along the block axis.
Automatic Block Size
.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-end: 20px;
block-size: 100px;
}
The element has an explicit logical block size and is positioned using its block-end offset.
Maximum Block Size
.panel {
position: absolute;
inset-block-end: 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-end property is not inherited. Its initial value is auto.
Parent Offset
.parent {
position: relative;
inset-block-end: 20px;
}
A child does not automatically inherit this offset.
Explicit Inheritance
.child {
position: relative;
inset-block-end: inherit;
}
Reset to Initial Value
.child {
inset-block-end: initial;
}
This resets the property to auto.
Reset with unset
.child {
inset-block-end: unset;
}
Because the property is not inherited, unset behaves like initial.
inset-block-end Example
This example compares how the same inset-block-end value maps to different physical sides in horizontal and vertical writing modes.
HTML Example
<div class="inset-block-end-demo">
<div class="demo-panel">
<h3>Horizontal Writing</h3>
<div class="demo-container horizontal">
<div class="demo-box">Block-End</div>
</div>
</div>
<div class="demo-panel">
<h3>Vertical Writing</h3>
<div class="demo-container vertical">
<div class="demo-box">Block-End</div>
</div>
</div>
</div>
CSS Example
.inset-block-end-demo {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.inset-block-end-demo .demo-panel {
flex: 1 1 220px;
min-width: 0;
}
.inset-block-end-demo h3 {
margin: 0 0 12px;
font-size: 1rem;
}
.inset-block-end-demo .demo-container {
position: relative;
height: 180px;
border: 2px solid #2563eb;
background-color: #eff6ff;
}
.inset-block-end-demo .demo-box {
position: absolute;
inset-block-end: 20px;
inset-inline-end: 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-end-demo .horizontal {
writing-mode: horizontal-tb;
}
.inset-block-end-demo .vertical {
writing-mode: vertical-rl;
}
Horizontal Writing
Vertical Writing
In horizontal writing mode, the box is positioned 20 pixels from the bottom edge. In vertical right-to-left writing mode, the same property positions it 20 pixels from the left edge.
Try a Larger Offset
.inset-block-end-demo .demo-box {
inset-block-end: 40px;
}
The box moves farther from the logical block-end edge.
Try vertical-lr
.inset-block-end-demo .vertical {
writing-mode: vertical-lr;
}
The logical block-end edge now corresponds to the right side instead of the left.
Common Mistakes
Forgetting to Set position
.box {
inset-block-end: 20px;
}
The offset has no positioning effect when the element is statically positioned.
Using Multiple Values
.box {
inset-block-end: 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-end: 20;
}
Nonzero CSS lengths require an appropriate unit.
Assuming Block-End Always Means Bottom
Block-end maps to bottom in horizontal writing mode, but it maps to left or right in vertical writing modes.
Confusing inset-block-end with margin-block-end
The inset-block-end property controls positioning. The margin-block-end property controls logical outer spacing.
Mixing Conflicting Physical and Logical Offsets
.box {
bottom: 10px;
inset-block-end: 20px;
}
In horizontal writing mode, both declarations target the bottom offset. The cascade determines which value applies.
Assuming auto Means Zero
The auto value is resolved according to the 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-end:
- The property sets the logical block-end 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-end corresponds to bottom. - In
vertical-rl, block-end corresponds to left. - In
vertical-lr, block-end corresponds to right. - 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 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-startto control the opposite logical block edge. - Test positioned content for overlap, clipping, and overflow.
Browser Support
The CSS inset-block-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-block-end.
Specifications
The inset-block-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.
For additional documentation and examples, consult MDN Web Docs.
