HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
Set the maximum height of a <p> element to 50 pixels
The max-height
property defines the maximum height of an element.
If the content is larger than the maximum height, it will overflow. How the container will handle the overflowing content is defined by the overflow property.
If the content is smaller than the maximum height, the
max-height
property
has no effect.
max-height
. The value of the
max-height
property overrides
the height property.
Default value: | none |
---|---|
Inherited: | no |
Animatable: | yes, see individual properties. Read about animatable Try it |
Version: | CSS2 |
JavaScript syntax: | object.style.maxHeight="100px" Try it |
The numbers in the table specify the first browser version that fully supports the property.
Property | |||||
---|---|---|---|---|---|
max-height | 1.0 | 7.0 | 1.0 | 2.0.2 | 7.0 |
Value | Description | Demo |
---|---|---|
none | No maximum height. This is default | Play it » |
length | Defines the maximum height in px, cm, etc. Read about length units | Play it » |
% | Defines the maximum height in percent of the containing block | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
CSS tutorial: CSS Height and Width
CSS reference: min-height property
HTML DOM reference: maxHeight property