CSS Max-width
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 then the max-width then it will go to the next line and if the content is smaller then max-width then it has no effect.
- Syntax: max-width: none|length|initial|inherit;
Property Values:
- none: It is the default value and it does not contains max-width.
Syntax: max-width: none;
CODE:
Result:
- length: This property is used to set the length of max-width. The length can be set in the form of px, cm, etc.
Syntax: max-width: length;
CODE:
Result:
- percentage (%): This property is used to set the max-width in the form of a percentage.
Syntax: max-width: %;
CODE:
Result:
- initial: It is used to set max-width property to its default value.
Syntax: max-width: initial;
CODE:
Result:
- inherit: This property is inherited from its parent.
You may also like: CSS Display