CSS inset-block Property
Shorthand for inset-block-start and inset-block-end for positioned elements
Syntax
inset-block: auto | <length> | <percentage>;Values
| Value | Description |
|---|---|
| auto | Automatic positioning |
| 0 | Stretches in block direction |
| <length> | Fixed offset (1-2 values) |
Example
.stretch-vertically {
position: absolute;
inset-block: 0;
}Understanding CSS inset-block
The CSS inset-block property shorthand for inset-block-start and inset-block-end for positioned elements. As part of the Box Model module in CSS, it is one of the most commonly used properties for controlling the visual presentation of web pages.
You can set inset-block to values such as auto, 0, <length>, among others. Each value changes how the browser renders the affected element, giving you fine-grained control over your page layout and design. Choosing the right value depends on the specific design requirements of your project.
Common use cases for the inset-block property include responsive web design, component-based layouts, and creating visually consistent interfaces across devices. It works closely with related properties like inset, inset-inline, top to achieve complex styling effects. Understanding how these properties interact helps you write cleaner, more maintainable stylesheets.
Browser support for inset-block is excellent across all modern browsers including Chrome, Firefox, Safari, and Edge. For older browsers, consider using fallback values or progressive enhancement strategies. The property can also be set dynamically via JavaScript using element.style.insetBlock or the CSS custom properties (variables) approach for theming.
Related Properties
insetShorthand for top, right, bottom, and left properties
inset-inlineShorthand for inset-inline-start and inset-inline-end for positioned elements
topSpecifies the vertical offset of a positioned element from its top edge
bottomSpecifies the vertical offset of a positioned element from its bottom edge
positionSets the positioning method used for an element
Explore More CSS Properties
Browse our complete reference of 251 CSS properties with syntax, examples, and tips.