CSS
[Link]
Max-Width property
⚫ The max-width property in CSS is used to define the maximum width of an
element.
⚫ The value of the width cannot be larger than the value by max-width.
⚫ If the content is larger than the max-width then it will go to the next line
and if the content is smaller than the max-width then it has no effect.
Syntax:
max-width: none | length | percentage (%) | initial |
inherit;
❖ Property Values
All the properties are described well in the example below.
➢ none: It is the default value and it does not contain max-width.
➢ length: This property is used to set the length of max-width. The length
can be set in the form of px, cm, etc.
➢ percentage (%): This property is used to set the max-width in the form
of a percentage.
➢ initial: It is used to set an element’s CSS property to its default value.
The initial keyword can be used for any CSS property, and on any HTML
element.
➢ inherit: This property is used to inherit a property to an element from
its parent element property value. The inherit keyword can be used for
inheriting any CSS property, and on any HTML element.
©Topperworld
CSS
Example:
<!DOCTYPE html>
<html>
<head>
<title>max-width property</title>
<!-- max-width CSS property -->
<style>
p{
max-width: none;
color: white;
background-color: green;
}
</style>
</head>
<body>
<p> Topper World : A computer science portal </p>
</body>
</html>
©Topperworld
CSS
Output:
©Topperworld