Spec-Zone.ru › CSS

`block-size` CSS property

Baseline Widely available

This feature is well established and works across many devices and browser versions. It's been available across browsers since September 2021.

The block-size CSS property defines the size of an element's block along the block axis. If the writing-mode is horizontal, it corresponds to the height; if the writing mode is vertical, it corresponds to the width. A related property is inline-size, which defines the other dimension of the element.

Try it

block-size: 150px;
writing-mode: horizontal-tb;
block-size: 150px;
writing-mode: vertical-rl;
block-size: auto;
writing-mode: horizontal-tb;
block-size: auto;
writing-mode: vertical-lr;
<section class="default-example" id="default-example">
  <div class="transition-all" id="example-element">
    This is a box where you can change the block-size.
  </div>
</section>
#example-element {
  display: flex;
  flex-direction: column;
  background-color: #5b6dcd;
  justify-content: center;
  color: white;
}

Syntax

/* <length> values */
block-size: 300px;
block-size: 25em;
block-size: anchor-size(height);
block-size: calc(anchor-size(--my-anchor block) * 0.75);

/* <percentage> values */
block-size: 75%;

/* Keyword values */
block-size: max-content;
block-size: min-content;
block-size: fit-content;
block-size: fit-content(20em);
block-size: auto;

/* Global values */
block-size: inherit;
block-size: initial;
block-size: revert;
block-size: revert-layer;
block-size: unset;

Values

The block-size property takes the same values as the width and height properties.

Formal definition

Initial value auto
Applies to same as width and height
Inherited no
Percentages block-size of containing block
Computed value same as width and height
Animation type $1$, <a href="/en-US/docs/Web/CSS/Reference/Values/percentage#interpolation" title="Values of the <percentage> CSS data type are interpolated as real, floating-point numbers.">percentage</a> or calc();

Formal syntax

block-size = 
  <'width'>

Examples

Block size with vertical text

HTML

<p class="exampleText">Example text</p>

CSS

.exampleText {
  writing-mode: vertical-rl;
  background-color: yellow;
  block-size: 200px;
}

Result

Specifications

Specification
CSS Logical Properties and Values Module Level 1
# propdef-block-size

Browser compatibility

Desktop Mobile
Chrome Edge Firefox Opera Safari Chrome Android Firefox for Android Opera Android Safari on iOS Samsung Internet WebView Android WebView on iOS
block-size
57
8
79
79
41
44
15
12.1
5.1
57
18
41
43
14
12.2
5
7.0
1.0
57
4.4
12.2
5
anchor-size
125
125
147
111
26
125
147
83
26
27.0
125
26
auto
8
79
41
15
5.1
18
41
14
5
1.0
4.4
5
fit-content
57
79
94
41
44
12.1
57
94
41
43
12.2
7.0
57
12.2
fit-content_function
No
No
91
No
No
No
No
No
No
No
No
No
max-content
57
79
66
41
44
12.1
57
66
41
43
12.2
5.0
57
12.2
min-content
57
79
66
41
44
12.1
57
66
41
43
12.2
5.0
57
12.2
stretch
138
138
No
122
27
138
No
91
27
30.0
138
27

See also

  • The mapped physical properties: width and height
  • writing-mode

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Properties/block-size

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API