CSS block-size Property

Beginner
⏱️ 5 min read
📚 Updated: Jun 2026
🎯 4 Examples
Layout & Sizing

What You’ll Learn

The block-size property sets an element’s size along the block axis — the direction text flows in blocks. In everyday horizontal layouts, that usually means height. It is part of CSS logical sizing, which adapts better to different writing modes.

01

Block Axis

Size in the flow direction.

02

Syntax

Length, %, and keywords.

03

auto Default

Content-based sizing.

04

Writing Modes

Works beyond height.

05

Logical Pairs

Use with inline-size.

06

Responsive

Percentages and fit-content.

Definition and Usage

The block-size CSS property controls the size of an element in the block dimension. In horizontal writing modes such as English, the block axis runs top to bottom, so block-size behaves like height.

In vertical writing modes, the block axis runs sideways, so the same property controls width instead. That makes block-size useful for international layouts and components that must work in more than one writing direction.

💡
Beginner Tip

If you are building a simple left-to-right page, think of block-size: 200px; as “make this box 200px tall.” Pair it with inline-size when you want logical width and height together.

📝 Syntax

Write block-size with a length, percentage, or sizing keyword:

syntax.css
selector {
  block-size: <length> | <percentage> | auto | max-content | min-content | fit-content;
}

Basic Example

block-size.css
.box {
  block-size: 200px;
  background-color: lightblue;
}

Syntax Rules

  • The initial value is auto, which sizes the element based on content and other CSS rules.
  • Length values such as px, rem, and vh set a fixed block size.
  • Percentages are relative to the containing block’s block size.
  • Keywords like min-content, max-content, and fit-content size from content.
  • Use min-block-size and max-block-size to add lower and upper limits.

⚡ Quick Reference

QuestionAnswer
Initial valueauto
Applies toAll elements
InheritedNo
AnimatableYes, as a length
Common useLogical height, responsive panels, writing-mode-aware layouts

Default Value

The default value of block-size is auto. That means the browser calculates the block dimension from the element’s content, padding, borders, margins, and related sizing properties such as min-block-size and max-block-size.

💎 Property Values

These are the most common values you will use with block-size.

ValueExampleMeaning
Lengthblock-size: 200px;Sets a fixed block size using units like px, em, or rem
Percentageblock-size: 50%;Sizes relative to the containing block’s block dimension
autoblock-size: auto;Lets the browser calculate size from content and layout rules
max-contentblock-size: max-content;Uses the content’s intrinsic maximum block size
min-contentblock-size: min-content;Uses the content’s intrinsic minimum block size
fit-contentblock-size: fit-content;Fits the content without exceeding available space
Horizontal writing → block-size = height Vertical writing → block-size = width
200px

A fixed block size in pixels or other length units.

Most common for cards and panels.

50%

Half of the parent container’s block size.

Useful in responsive layouts.

auto

Size grows or shrinks with content naturally.

Default browser behavior.

fit-content

Fits content while respecting available space.

Good for flexible components.

Block Size and Writing Modes

block-size follows the writing mode instead of always mapping to vertical height. That is the main reason to choose it over physical properties like height and width.

Horizontal writing (writing-mode: horizontal-tb)

block-size controls height

Vertical writing (writing-mode: vertical-rl)

block-size controls width
  • inline-size is the logical counterpart for the inline axis (usually width in English).
  • min-block-size and max-block-size set lower and upper limits on the block axis.
  • Logical properties help components stay correct when text direction or writing mode changes.

block-size vs height

PropertyAxisBest for
block-sizeBlock axis (depends on writing mode)International layouts, reusable components, logical sizing systems
heightAlways verticalSimple pages with fixed vertical sizing in horizontal writing
inline-sizeInline axis (depends on writing mode)Logical width paired with block-size
widthAlways horizontalSimple fixed-width boxes in horizontal writing

👀 Live Preview

Three boxes with different fixed block-size values in a normal horizontal layout:

block-size: 3rem
block-size: 5rem
block-size: 7rem

In horizontal writing, these values control height.

Examples Gallery

Try block-size with fixed lengths, percentages, content keywords, and vertical writing mode.

📚 Fixed Block Sizing

Set an exact block dimension when you need predictable panel or card heights.

Example 1 — Fixed Block Size with Pixels

Set a box to 200px along the block axis. In horizontal writing, that means 200px tall.

block-size-fixed.html
<style>
  .box {
    block-size: 200px;
    background-color: lightblue;
  }
</style>

<div class="box">
  This box has a block size of 200px.
</div>
Try It Yourself

How It Works

The box keeps a 200px block dimension regardless of how much text it contains, unless overflow rules allow content to spill out.

Example 2 — Percentage Block Size

Size a child element to half of its parent’s block size.

block-size-percent.html
<style>
  .parent {
    block-size: 240px;
    background: #f1f5f9;
  }
  .child {
    block-size: 50%;
    background: #93c5fd;
  }
</style>

<div class="parent">
  <div class="child">50% block size</div>
</div>
Try It Yourself

How It Works

The child fills half of the parent’s block dimension. Percentages only work when the parent has a defined block size.

🎨 Content-Based Sizing

Use sizing keywords when the block dimension should follow content instead of a fixed number.

Example 3 — auto, min-content, and fit-content

Compare default content sizing with keyword-based block sizes.

block-size-keywords.css
.auto { block-size: auto; }
.min { block-size: min-content; }
.fit { block-size: fit-content; }
Try It Yourself

How It Works

auto is the normal flow size, min-content shrinks to the smallest content size, and fit-content balances content size with available space.

Example 4 — Block Size in Vertical Writing Mode

When writing mode changes, block-size controls the sideways dimension instead of height.

block-size-writing-mode.css
.vertical-panel {
  writing-mode: vertical-rl;
  block-size: 180px;
  background: #ddd6fe;
  padding: 1rem;
}
Try It Yourself

How It Works

With writing-mode: vertical-rl, the block axis runs horizontally, so block-size: 180px; sets the panel width rather than its height.

🧠 How block-size Works

1

The browser finds the block axis

Writing mode decides which direction is block. In normal English pages, that is top to bottom.

Writing mode
2

You set a block-size value

Choose a length, percentage, or keyword such as 200px, 50%, or fit-content.

CSS rule
3

Limits and content are applied

min-block-size, max-block-size, padding, and content all influence the final size.

Box model
=

Logical block dimension

The element gets a predictable size along the block axis, even when writing mode changes.

Universal Browser Support

block-size is supported in all modern browsers. Internet Explorer does not support logical sizing properties.

Baseline · Modern browsers

Logical sizing in today’s browsers

Chrome, Firefox, Safari, Edge, and Opera all support block-size and related logical properties in current versions.

96% Modern browser support
Google Chrome57+ · Desktop & Mobile
Full support
Mozilla Firefox41+ · Desktop & Mobile
Full support
Apple Safari12.1+ · macOS & iOS
Full support
Microsoft Edge79+ · Chromium
Full support
Opera44+ · Modern versions
Full support

Fallback behavior

For older browsers, you can pair logical properties with physical ones such as height as a fallback.

💻
Internet Explorer No support · Use height or width instead
None
block-size property 96% supported

Bottom line: Use block-size confidently in modern projects, especially when writing mode matters.

Conclusion

The block-size property is a logical way to control an element’s size along the block axis. In everyday horizontal layouts it often behaves like height, but it stays correct when writing mode or text direction changes.

By using block-size with values like pixels, percentages, and content keywords, you can build layouts that are more flexible and easier to adapt across languages and screen sizes.

💡 Best Practices

✅ Do

  • Use block-size with inline-size for logical layout systems
  • Set a parent block size when using percentage values on children
  • Combine with min-block-size and max-block-size for flexible limits
  • Prefer logical properties in components that may change writing mode
  • Test layouts in both horizontal and vertical writing when possible

❌ Don’t

  • Mix confusing physical and logical sizing without a reason
  • Expect percentages to work when the parent block size is undefined
  • Forget overflow behavior when content exceeds a fixed block size
  • Assume block-size always equals height in every layout
  • Skip fallbacks if you must support very old browsers

Key Takeaways

Knowledge Unlocked

Five things to remember about block-size

Use these points when sizing elements logically.

5
Core concepts
📝02

auto Default

Content-based size.

Default
🔄03

Writing Mode

Changes which side grows.

Context
📈04

Percentages

Relative to parent.

Responsive
🛠05

Logical Pair

Use with inline-size.

System

❓ Frequently Asked Questions

The block-size property sets an element's size along the block axis. In normal horizontal writing, that is the height. In vertical writing modes, it becomes the width.
The initial value is auto, which lets the browser calculate the block dimension from content, padding, borders, and other sizing rules.
height always controls vertical size. block-size follows the writing mode, so it stays correct when text flows vertically or when you support multiple languages and layouts.
Common values include length units like px and rem, percentages, auto, max-content, min-content, and fit-content().
For simple English pages, height is still common. Use block-size when you want logical sizing that adapts to writing mode, especially in international or vertical layouts.

Practice in the Live Editor

Open the HTML editor, set block-size, and preview logical sizing instantly.

HTML Editor →

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