English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The height CSS attribute specifies the height of the content area of an element. The content area does not include padding, border, or margin. More information can be found inCSS box model.
The following table explains the usage and version history of this attribute, as well as the syntax of using this attribute in JavaScript scripts.
Default value: | auto |
---|---|
Applies to: | Except for unreplaced embedded elements, All elements outside table rows and row groups |
Inheritance: | No |
Can be animated: | Yes.Please refer to Animation attributes. |
Version: | CSS 1,2,3 |
JavaScript syntax: | object.style.height="100px" |
The syntax of this attribute is as follows:
height: length | percentage | auto | initial | inherit
The following example demonstrates how to use the height attribute.
p { height: 50px; background-color: #f0e68c; }Test to see‹/›
The following table describes the value of this attribute.
Value | Description |
---|---|
length | Specify the height in units such as px, pt, cm, em, etc., and the height cannot be negative. |
percentage | Specify the height as a percentage. The percentage is calculated relative to the height of the element's containing block. Negative percentage values are not allowed. |
auto | The browser will calculate the height of the specified element based on the values of other attributes. This is the default value. |
initial | Set this attribute to its default value. |
inherit | If specified, the associated element adopts the height attribute value of its parent element. |
Browser compatibility of the height attribute, the numbers in the table below represent the minimum version number of the browser that supports this attribute; all mainstream browsers support this attribute.
|
Please refer to the tutorials related to the following content:CSS Box Model,CSS dimensions.
Related attributes:max-height,min-height.