max-inline-size
The max-inline-size CSS property corresponds to the max-height or the max-width depending on the element's writing-mode.
CSS
JS
object.style.maxInlineSize = "value";
Values
<'max-inline-size'> = <'max-width'>
<'max-width'> = none | <length-percentage> | min-content | max-content | fit-content( <length-percentage> )
none
No limit on the size of the box.
<length-percentage> = [ <length> | <percentage> ]
<length>
Specifies the length using a number followed by a unit of measurement.
<percentage>
Specifies the percentage using a number followed by a percent sign (%).
min-content
Represents the largest min-content contribution of the items occupying the track.
max-content
Represents the largest max-content contribution of the items occupying the track.
fit-content()
Represents the formula max(minimum, min(limit, max-content)), where minimum represents an auto minimum (which is often, but not always, equal to a min-content minimum), and limit is the track sizing function passed as an argument to fit-content(). This is essentially calculated as the smaller of minmax(auto, max-content) and minmax(auto, limit).
Initial
fit-content
length
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, yellow);
block-size: 100px;
inline-size: 100px;
max-inline-size: 50px;
}
div:nth-of-type(2) {
writing-mode: vertical-lr;
}
</style>
</head>
<body>
<div>length</div>
<div>length</div>
</body>
</html>
max-content
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, yellow);
block-size: 100px;
inline-size: 100px;
max-inline-size: max-content;
}
div:nth-of-type(2) {
writing-mode: vertical-lr;
}
</style>
</head>
<body>
<div>max-content</div>
<div>max-content</div>
</body>
</html>
min-content
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, yellow);
block-size: 100px;
inline-size: 100px;
max-inline-size: min-content;
}
div:nth-of-type(2) {
writing-mode: vertical-lr;
}
</style>
</head>
<body>
<div>min-content</div>
<div>min-content</div>
</body>
</html>
none
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, yellow);
block-size: 100px;
inline-size: 100px;
max-inline-size: none;
}
div:nth-of-type(2) {
writing-mode: vertical-lr;
}
</style>
</head>
<body>
<div>none</div>
<div>none</div>
</body>
</html>
percentage
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, yellow);
block-size: 100px;
inline-size: 100px;
max-inline-size: 50%;
}
div:nth-of-type(2) {
writing-mode: vertical-lr;
}
</style>
</head>
<body>
<div>percentage</div>
<div>percentage</div>
</body>
</html>
JS
<!doctype html>
<html>
<head>
<style>
div {
background-image: linear-gradient(135deg, white, yellow);
block-size: 100px;
inline-size: 100px;
}
div:nth-of-type(2) {
writing-mode: vertical-lr;
}
</style>
<script>
function mouseover(value) {
var elements = document.getElementsByTagName("div");
for (var i = 0; i < elements.length; ++i) {
elements[i].style.maxInlineSize = value;
}
}
</script>
</head>
<body>
<button onmouseover="mouseover(value)" value="fit-content(50px)">fit-content</button>
<button onmouseover="mouseover(value)" value="50px">length</button>
<button onmouseover="mouseover(value)" value="max-content">max-content</button>
<button onmouseover="mouseover(value)" value="min-content">min-content</button>
<input onmouseover="mouseover(value)" type="button" value="none">
<button onmouseover="mouseover(value)" value="50%">percentage</button>
<div>max-inline-size</div>
<div>max-inline-size</div>
</body>
</html>
Internal
External