max-inline-size
max-inline-size sets an upper limit on the size of an element in the direction its text runs. In horizontal text it works like max-width, and in vertical text like max-height.
Syntax
<'max-width'>Preview
Code
.box {
writing-mode: vertical-rl;
inline-size: 18em;
max-inline-size: 8em;
}Controls
About
Writing the value
- A length such as
8em: never larger than that. none: the initial value. No upper limit.min-content,max-contentandfit-content: use a size taken from the content as the limit.min-contentis the length with every possible line break taken.
As on the inline-size page, the preview box is vertical (writing-mode: vertical-rl), so max-inline-size is an upper limit on its height. A helper declaration makes it tall with inline-size: 18em, but it stops at the limit, and text that does not fit wraps into the next column to the left. Dragging the handle at the bottom right does not make it taller than the limit.
In vertical text, a % is a share of the parent's height, and it has no effect unless that height is set, so this page does not offer it.
When to use it
To limit the line length of text for readability (such as max-inline-size: 40em). In vertical text, it still limits the line length.
Watch out
- It sets the same thing as
max-widthin horizontal text andmax-heightin vertical text, so when both are written, the later one wins. - When
min-inline-sizeis larger, the lower limit wins over the upper one. - Works in all major browsers.