CSSmax-block-size Property
Example
Set the maximum size of a <div> element to 60 pixels in the block direction:
max-block-size: 60px;
}
More "Try it Yourself" examples below.
Definition and Usage
Themax-block-size property specifies the maximum size of an element in the block direction.
If the content is smaller than the maximum size in block direction, themax-block-size property value has no effect.
If the content is larger than the maximum size in block direction, themax-block-size property value will be applied.
Note: The related CSS propertywriting-mode defines block direction, and this affects the result of themax-block-size property. For pages in English, block direction is downward and inline direction is left to right.
The CSSmax-block-size property is very similar to CSS propertiesmax-height andmax-width, but themax-block-size property is dependent on block direction.
| Default value: | auto |
|---|---|
| Inherited: | no |
| Animatable: | yes.Read aboutanimatableTry it |
| Version: | CSS3 |
| JavaScript syntax: | object.style.maxBlockSize="60px"Try it |
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
| Property | |||||
|---|---|---|---|---|---|
| max-block-size | 57.0 | 79.0 | 41.0 | 12.1 | 44.0 |
CSS Syntax
Property Values
| Value | Description | Demo |
|---|---|---|
| auto | Default. The element's default max-block-size value. | Demo ❯ |
| length | Specifies max-block-size in px, pt, cm, etc.Read about length units | Demo ❯ |
| % | Specifies max-block-size in percent relative to size of parent element on the corresponding axis. | Demo ❯ |
| initial | Sets this property to its default value.Read aboutinitial | |
| inherit | Inherits this property from its parent element.Read aboutinherit |
More Examples
Writing mode
With thewriting-mode property value of a <div> element set to vertical-lr, the block direction is changed from downwards to sideways, and this affects how themax-block-size property work:
max-block-size: 60px;
writing-mode: vertical-lr;
}
Max-block-size vs Block-size
See how one <div> element withblock-size 100px, and another <div> withmax-block-size 100px, react differently with changing content size:
max-block-size: 100px;
}
#div2 {
block-size: 100px;
}
Related Pages
CSS block-size property:CSS Block-size property
CSS min-block-size property:CSS Min-block-size property
CSS max-height property:CSS Max-height property
CSS max-width property:CSS Max-width property
CSS writing-mode property:CSS Writing-mode property

