CSS block-size Property

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The block-size property sets the size of an element along the block axis. In a horizontal writing mode it behaves like height. In a vertical writing mode it behaves like width.

It is not inherited. The initial value is auto. Pair it with inline-size for the other axis, and with writing-mode when text direction changes.

Logical property.

Standard-track and Baseline Widely available. Prefer block-size over height when a layout must stay correct for both horizontal and vertical writing modes. fit-content() is experimental here; stretch has limited support.

CSS Syntax

syntax.css
block-size: auto | <length> | <percentage> | min-content | max-content | fit-content | initial | inherit;

Values match width / height. Newer keywords like stretch have limited support.

Property Values

ValueDescriptionTry it
autoDefault. Browser sizes the box from contentTry it
<length>Fixed size such as 150px, 12rem, or 40vhTry it
<percentage>Percent of the containing block’s block sizeTry it
with writing-modeIn vertical mode, block-size maps to physical widthTry it
initialResets to autoTry it
inheritTakes the parent’s block-sizeTry it

How to Use block-size

Think in writing-mode terms: size the block axis, not “always top–bottom.”

  1. Use block-size where you would reach for height in a horizontal layout.
  2. Pick auto, a length, or a percentage of the containing block.
  3. Add min-block-size / max-block-size when you need floors or caps.
  4. Test with writing-mode if the page may switch to vertical text.
PieceRequired?Role
Block or sized boxYesSame applicability rules as height
block-size valueYesauto, length, percentage, or keyword
Containing block sizeFor %Percentage uses the parent’s block size
writing-modeOptionalChooses whether block maps to height or width

Live Preview

Change block-size on the sample box. In the default horizontal mode, this acts like height.

The outer frame is 220px tall so 50% has a parent block size to resolve against.

Box
Box

block-size: 150px

CSS Examples

Each snippet focuses on block-size. Use Try It Yourself for a live editor.

Example 1 — Fixed Length

Set an exact block size. In horizontal mode this is like height.

CSS
<style>
  div {
    block-size: 150px;
  }
</style>

<div>150px block</div>
Try It Yourself

How It Works

  1. Pick a length. 150px sets the block-axis size.
  2. Horizontal mode. With default writing mode, that size is the physical height.
  3. Content sits inside. Extra text can overflow or grow the box depending on other rules.
  4. Other units work. Try rem, em, or vh the same way.

Example 2 — Percentage of Parent

Size a child as half of the parent’s block size.

CSS
<style>
  .parent {
    block-size: 220px;
  }

  .child {
    block-size: 50%;
  }
</style>

<div class="parent">
  <div class="child">Half of parent</div>
</div>
Try It Yourself

How It Works

  1. Give the parent a block size. 220px defines the containing block.
  2. Use a percentage on the child. 50% resolves to 110px here.
  3. Axis matters. The percent uses the parent’s block size, not inline size.
  4. Same idea as height %. In horizontal mode the math matches height: 50%.

Example 3 — Vertical Writing Mode

With vertical text, block-size maps to physical width.

CSS
<style>
  div {
    writing-mode: vertical-rl;
    block-size: 150px;
  }
</style>

<div>Block axis</div>
Try It Yourself

How It Works

  1. Set vertical writing. writing-mode: vertical-rl rotates the axes.
  2. Block becomes horizontal. Lines stack sideways; the block axis is now left–right.
  3. block-size follows. 150px controls physical width, not height.
  4. Why logical wins. One rule keeps sizing correct when writing mode changes.

Edge Cases & Pitfalls

Most confusion comes from mixing logical and physical sizing.

map

Not always the same as height

In vertical writing modes, block-size maps to width. Do not assume it always means top–bottom size.

conflict

Mixing with height can conflict

Setting both height and block-size on the same element can produce unexpected results. Prefer one system.

percent

Percentage needs a sized containing block

Percentages resolve against the containing block’s block size. If the parent’s block size is auto, the percent often computes to auto — the same trap as height: %.

limits

min- / max-block-size override

Those properties can stop a box from shrinking or growing past a limit, just like min-height / max-height.

box

box-sizing still applies

With border-box, padding and border count inside the size. With content-box, they add outside it.

Browser Support

block-size is a browser layout property. Node.js, Deno, and Bun do not apply it.

✓ Baseline · Widely available since 2020

block-size

Chrome 57+, Firefox 41+, Safari 12.1+, Edge 79+, Opera 44+, Samsung Internet 7+. Same value set as width/height; stretch and fit-content() remain limited or experimental.

96% Common values
Google Chrome 57+
Full support
Mozilla Firefox 41+
Full support
Apple Safari 12.1+
Full support
Microsoft Edge 79+
Full support
Opera 44+
Full support
Samsung Internet 7.0+
Full support
Internet Explorer No support
Not supported
block-size Widely supported

Bottom line: Safe for modern sites. Prefer logical sizing when writing-mode flexibility matters. Skip Internet Explorer. Treat fit-content() as experimental and stretch as limited.

Key Takeaways

  • Role: size the block axis — height in horizontal mode, width in vertical mode.
  • Common values: auto, lengths, and percentages (same as height).
  • Initial value: auto. Not inherited.
  • Tip: use with inline-size for fully logical box sizing.

One line: block-size is the logical version of height — it follows the writing mode’s block axis.

Frequently Asked Questions

It sets the size of an element along the block axis. In horizontal writing modes it maps to height; in vertical writing modes it maps to width.
The initial value is auto. The browser sizes the box from content and layout rules.
height always controls the vertical size. block-size follows writing-mode, so it adapts when text runs vertically.
Use it when you want logical sizing that stays correct across horizontal and vertical writing modes.
No. Percentages resolve against the block size of the containing block.
It is Baseline and widely available: Chrome 57+, Firefox 41+, Safari 12.1+, Edge 79+, Opera 44+. Internet Explorer does not support it. It is a browser layout property, not a Node.js feature.

Next: border

Learn the shorthand that sets border width, style, and color together.

border tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful