Property Description
The height property sets the height of an element. This does not include padding, borders, or margins.
This property has the following syntax:
height: auto|length|%|initial|inherit;
Property Values
| Value | Description |
|---|---|
| auto | (default) The browser calculates the height |
| length | Defines the height in px, cm, etc. |
| % | Defines the height in percent of the containing block |
| initial | Specifies that the value of the property should be set to the default value |
| inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example sets the height and width for a paragraph.
p.note {
height: 100px;
width: 100px;
}
Browser Support
| Chrome | Firefox | IE | Safari | Opera |
|---|---|---|---|---|
| 1.0 | 1.0 | 4.0 | 1.0 | 7.0 |
Miscellaneous Information
| Inherited: | No |
|---|---|
| Defined In: | CSS1 |
| Default Value: | auto |
Property Description
The max-height property sets the maximum height of an element. This does not include padding, borders, or margins.
This property has the following syntax:
max-height: none|length|%|initial|inherit;
Property Values
| Value | Description |
|---|---|
| none | (default) No maximum height |
| length | Defines the maximum height in px, cm, etc. |
| % | Defines the maximum height in percent of the containing block |
| initial | Specifies that the value of the property should be set to the default value |
| inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example sets the maximum height for a paragraph.
p {
max-height:20px;
background-color: yellow;
}
<p>The maximum height of this paragraph is set to 20px.
The maximum height of this paragraph is set to 20px.
The maximum height of this paragraph is set to 20px.
The maximum height of this paragraph is set to 20px.
The maximum height of this paragraph is set to 20px.
The maximum height of this paragraph is set to 20px.
The maximum height of this paragraph is set to 20px.
The maximum height of this paragraph is set to 20px.
</p>
This produces the following result:
The maximum height of this paragraph is set to 20px. The maximum height of this paragraph is set to 20px. The maximum height of this paragraph is set to 20px. The maximum height of this paragraph is set to 20px. The maximum height of this paragraph is set to 20px. The maximum height of this paragraph is set to 20px. The maximum height of this paragraph is set to 20px. The maximum height of this paragraph is set to 20px.
Browser Support
| Chrome | Firefox | IE | Safari | Opera |
|---|---|---|---|---|
| 1.0 | 1.0 | 7.0 | 2.0.2 | 7.0 |
Miscellaneous Information
| Inherited: | No |
|---|---|
| Defined In: | CSS2 |
| Default Value: | none |
Property Description
The min-height property sets the minimum height of an element. This does not include padding, borders, or margins.
This property has the following syntax:
min-height: length|%|initial|inherit;
Property Values
| Value | Description |
|---|---|
| length | (default is 0) Defines the minimum height in px, cm, etc. |
| % | Defines the minimum height in percent of the containing block |
| initial | Specifies that the value of the property should be set to the default value |
| inherit | Specifies that the value of the property should be inherited from the parent element |
Examples
This example sets the minimum height for a paragraph.
p {
min-height:100px;
background-color: yellow;
}
<p>The minimum height of this paragraph is set to 100px.</p>
This produces the following result:
The minimum height of this paragraph is set to 100px.
Browser Support
| Chrome | Firefox | IE | Safari | Opera |
|---|---|---|---|---|
| 1.0 | 3.0 | 7.0 | 2.0.2 | 4.0 |
Miscellaneous Information
| Inherited: | No |
|---|---|
| Defined In: | CSS2 |
| Default Value: | 0 |
