Maximum width

In this aticle we are going to learn about maximun width property, how we can set the maximum width of html element with a maximum width property in css to prevent the value of the width property from becoming larger than maximum width.

We learnt about css in general, fonts, colors, background colors, borders, margin padding, float, width and mimimum width in css so, we will be focusing on maximum width.

Maximum width

Maximum width is a css property used to set a width limit that the element can have. The element with maximum width can not have width larger than maximum width but can have the width smaller than maximum width.

We are going to give the div element maximum width of 190px, copy and paste below code.

<div style="max-width: 190px;">This is 190px maximum width of div element.</div>


So, we should have the following results.

This is 190px maximum width of div element.

We are going to increase the maximum width and we will set it to 200px, copy and paste below code.

<div style="max-width: 200px;">This is 200px maximum width of div element.</div>


So, we should have the following results.

This is 200px maximum width of div element.

We are going to decrease the maximum width and we will set it to 100px, copy and paste below code.

<div style="max-width: 100px;">This is 100px maximum width of div element.</div>


So, we should have the following results.

This is 100px maximum width of div element.

Let us create two elements with different maximum widths of 55px and 70px, copy and paste below code.

<div style="max-width: 550px;">This is 550px maximum width of div element.</div>

<div style="max-width: 700px;">This is 700px; maximum width of div element.</div>


So, we should have the following results.

This is 550px maximum width of div element.
This is 700px maximum width of div element.

Conclusion

In this article we learnt about maximum width property with examples, how we can set the maximum width of html element with a maximum width property in css to prevent the value of the width property from becoming larger than maximum width.