CSS height property
Example
Set the height and width of a paragraph:
p.ex
{
height:100px;
width:100px;
}
Try it »
There are more examples at the bottom of this page.
Property definition and usage
The height property sets the height of an element.
Note: The height property does not include padding, borders, or margins!
| Default value: | auto |
|---|---|
| Inherited: | no |
| Version: | CSS1 |
| JavaScript syntax: | object.style.height="50px" |
Browser support
The numbers in the table indicate the first browser version that supports this property.
| property | |||||
|---|---|---|---|---|---|
| height | 1.0 | 4.0 | 1.0 | 1.0 | 7.0 |
Attribute values
| Value | Description |
|---|---|
| auto | Default. The browser calculates the actual height. |
| length | Defines the height using units such as px, cm, etc. |
| % | A percentage height based on the containing block-level object. |
| inherit | Specifies that the value of the height property should be inherited from the parent element. |
More examples
Set the height of an image using a percentage
This example demonstrates how to set an element's height using a percentage value.
Related Articles
CSS Tutorial: CSS Dimension
CSS Tutorial: CSS Box model
CSS Reference Manual: width property