Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

block-size — logical block-axis size

block-size sets an element’s size along the block axis. It corresponds to height in horizontal writing modes and width in vertical writing modes, allowing layouts to adapt to writing-mode.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

block-size: <'width'>;

block-size sets an element’s block-axis size: it corresponds to height with writing-mode: horizontal-tb, and width with vertical-rl and vertical-lr. inline-size controls the perpendicular axis. The property does not switch an element to display: block.

The notation <'width'> means the value syntax of width, not literal text to paste. Common values include auto, a nonnegative length, a percentage, and min-content and max-content. The initial value is auto; the property is not inherited. Percentages follow the corresponding physical property's rules: do not assume a percentage height will work without a definite containing-block height.

For lengths and percentages, box-sizing determines whether the size targets the content box or border box. min-block-size and max-block-size can constrain the result. A fixed size can cause content overflow.

In the example, both elements have block-size: 80px and inline-size: 120px. With box-sizing: border-box, the expected border-box dimensions are 120 × 80 CSS pixels for #horizontal and 80 × 120 for #vertical.

Examples

<!doctype html>
<meta charset="utf-8">
<title>block-size</title>
<style>
  .box {
    display: block;
    box-sizing: border-box;
    block-size: 80px;
    inline-size: 120px;
    padding: 8px;
    border: 2px solid black;
    margin: 8px;
    background: lightblue;
  }
  #horizontal { writing-mode: horizontal-tb; }
  #vertical { writing-mode: vertical-rl; }
</style>
<div id="horizontal" class="box">A</div>
<div id="vertical" class="box">B</div>

Result

#horizontal: border-box width 120px, height 80px.
#vertical: border-box width 80px, height 120px.

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources