Sets the minimum width of an element. It limits the width property to be not smaller than the value specified in min-width.
Overview table0
min-width
min-width: calc()
min-width: fill-available
min-width: fit-content
min-width: inherit
min-width: length
min-width: max-content
min-width: min-content
min-width: none
min-width: percentage
Use min-width with any CSS selector to apply it.
/* Restrict all div elements to a min-width of 100px */
div { min-width: 100px }
Constrain the width of a div element using min-width and max-width attributes.
<style>
.width {
width:50%;
background:#eee;
}
.minwidth {
width: 50%;
min-width: 600px;
background: lightblue;
}
.maxwidth {
width: 50%;
max-width: 200px;
background: lightgreen
}
.content {
border:1px solid #c00;
padding:5px;
}
</style>
<h3>Resize the window to grow and shrink the div from max to min width.</h3>
<div class="width">
<p class="content">This div also has a width of 50%. <br/><br/>
Note that the div height increases to accommodate the flow of text.</p>
</div>
<div class="minwidth">
<p class="content">This div also has a width of 50%.<br /><br /> It also has a min-width of 600px.</p>
</div>
<div class="maxwidth">
<p class="content">This div also has a width of 50%.<br /><br /> It also has a max-width of 200px.</p>
</div>
Usage
CSS min width is well supported across most browsers. A few things to consider while usage:
The min-width/max-width attributes apply to floating and absolutely positioned block and inline-block elements, as well as some intrinsic controls. They do not apply to non-replaced inline elements, such as table rows and row/column groups. (A “replaced” element has intrinsic dimensions, such as an img or textArea.) This property is enabled only under the strict !DOCTYPE.
Related specificationsmin-width
Cascading Style Sheet Compatibility in Internet Explorer 7
Microsoft Developer Network: [Windows Internet Explorer API reference Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4