{"id":14057,"date":"2011-09-05T20:45:18","date_gmt":"2011-09-06T03:45:18","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14057"},"modified":"2021-01-15T10:24:16","modified_gmt":"2021-01-15T18:24:16","slug":"height","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/h\/height\/","title":{"rendered":"height"},"content":{"rendered":"\n

The height<\/code> property in CSS defines specifies the content height<\/a> of boxes and accepts any of the length values<\/a>.<\/p>\n\n\n\n

The \u201ccontent\u201d area is defined as the padding<\/a> and border<\/a> in addition to the height\/width or size the content itself takes up.<\/p>\n\n\n\n

Negative values like height: -100px<\/code> are not accepted. The height<\/code> property does not apply to non-replaced inline<\/a> elements including table columns and column groups.<\/p>\n\n\n\n

.wrap {\n  height: auto;    \/* auto keyword *\/\n\n  height: 120px;   \/* length values *\/\n  height: 10em;\n  height: 0;       \/* unit-less length is OK for zero *\/\n\n  height: 75%;     \/* percentage value *\/\n\n  height: inherit; \/* inherited value from parent element *\/\n}<\/code><\/pre>\n\n\n\n
<\/code>Check out this Pen!<\/a><\/pre>\n\n\n\n

If the height of the containing block is not specified explicitly, and the element is not absolutely positioned, the value of its height computes to auto (it will be as tall as the content inside it is, or zero if there is no content). If the elements content portion<\/b> requires more vertical space than available from the value assigned, the elements behavior is defined by the overflow<\/code><\/a> property.<\/p>\n\n\n\n

When using the keyword auto<\/code>, height<\/code> is calculated based on the elements content area<\/b> unless explicitly specified. This means a value based on a percentage is still that of the elements content area. Similarly, if the height of the container is set to a percentage value, a child elements percentage height is still based on the content area of that child element.<\/p>\n\n\n\n

Height can also be used as an animatable property.<\/a><\/p>\n\n\n

Browser support<\/h3>\n\n\n
IE<\/th>Edge<\/th>Firefox<\/th>Chrome<\/th>Safari<\/th>Opera<\/th><\/tr><\/thead>
All<\/td>All<\/td>All<\/td>All<\/td>All<\/td>All<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n
Android Chrome<\/th>Android Firefox<\/th>Android Browser<\/th>iOS Safari<\/th>Opera Mobile<\/th><\/tr><\/thead>
All<\/td>All<\/td>All<\/td>All<\/td>All<\/td><\/tr><\/tbody><\/table>
Source: caniuse<\/a><\/figcaption><\/figure>\n\n\n