CSS - Dimension




CSS Dimension

CSS includes height and width properties to help you specify the size of your elements.

The height and width can be set to auto (this is default. Means that the browser calculates the height and width), or be specified in length values, like px, cm, etc., or in percent (%) of the containing block.

Example

<!DOCTYPE html>
<html>
<head>
<style>
div {
    height: 250px;
    width: 55%;
    background-color: #0000ff;
}
</style>
</head>
<body>
<h2>Set the height and width of an element</h2>
<p>You can use a fixed height (i.e. pixels) or a percentage height. For more info, see height and width.</p>
<div></div>
</body>
</html>

Result

All CSS Dimension Properties

For Example
height Sets the height of an element
max-height Sets the maximum height of an element
max-width Sets the maximum width of an element
min-height Sets the minimum height of an element
min-width Sets the minimum width of an element
width Sets the width of an element