Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / CSS

min-width — minimum width

min-width sets a lower bound on an element’s width. It takes precedence over a conflicting max-width; its initial auto value does not always mean a zero minimum.

Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required

Syntax

min-width: auto | <length-percentage [0,∞]> | min-content | max-content | fit-content(<length-percentage [0,∞]>);

min-width constrains physical width, regardless of writing direction. It is not inherited. The minimum takes precedence over width and a conflicting max-width. With box-sizing: border-box, it includes padding and borders, but not margins.

Lengths and percentages must be nonnegative; percentages refer to the containing block’s width. min-content and max-content provide content-dependent constraints. The syntax also shows draft specification values—not a guarantee of browser support.

The initial value auto means an automatic minimum. For a flex item with a horizontal main axis, this can depend on content and prevent shrinking. min-width: 0 removes that automatic lower bound, but does not itself prevent content overflow.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>min-width</title>
<style>
  #box {
    box-sizing: border-box;
    width: 80px;
    min-width: 140px;
    max-width: 100px;
    padding: 10px;
    border: 2px solid;
  }
</style>
<div id="box">min-width</div>
<pre id="result"></pre>
<script>
  const box = document.getElementById('box');
  document.getElementById('result').textContent =
    box.getBoundingClientRect().width + 'px';
</script>
</html>

Result

140px

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources