Reputation: 3912
Giving max width to an html element limits its width in bigger screens. But one can make the width proportional to screen size like '95%' too.
Now, is it more advantageous to give max-width to main container of a page ? Why ?
Upvotes: 0
Views: 343
Reputation: 571
An element to which a max-width is applied will never be wider than the value specified even if the width property is set to be wider. There is an exception to this rule, however: if min-width is specified with a value greater than that of max-width, the container’s width will be the largest value, which in this case means that the min-width value will be the one that’s applied.
max-width is often used in conjunction with min-width to produce a width range for the element concerned.
If the contents of a block require more horizontal space than is allowed by the limits that have been set, the behavior is defined by the overflow property.
This style rule assigns a maximum width of 800 pixels and a minimum width of 200 pixels to main container with element with ID "main-container":
#main-container {
max-width: 800px;
min-width: 200px;
}
Upvotes: 1