Min - width & Max - Width
min - width :
The min-width property in CSS is used to set the minimum width of a specified elemen t.
The min-width property always overrides the width property whether followed before or after width in your declaration.
- If the content is smaller than the minimum width, then minimum width will be applied.
- If the content is larger than the minimum width, then min-width property has no effect.
Example :
In the below example, 1st div element takes width of element but 2nd div element’s minimum width is 300px.
This will produce the following result −
max - width :
The max-width property in CSS is used to set the maximum width of a specified element.
The max-width property always overrides the width property whether followed before or after width in your declaration.
- If the content is larger than the maximum width, then maximum width will be applied.
- If the content is smaller than the maximum width, then max-width property has no effect.
Example :
In the below example, 1st div element takes width of element but 2nd div element’s maximum width is 350px.
This will produce the following result −