The CSS height and width property is used to set the height and width of the content area of an element.
Height property
If the height of the container is not explicitly defined, and the element is not absolutely positioned (i.e., position: absolute;), the value of height property is set to auto. The min-height and max-height properties can also be used to control the size.
Syntax : height : auto | length | initial | inherit;
Property Values :
auto - It is a default value. Using this value browser is responsible for calculating the height of the element. Negative values are not allowed.
length - It specifies the height of an element using the length units such as px, cm, pt, etc. Negative values are not allowed.
% - It defines the height of the container in %. Negative values are not allowed.
initial - It is used to set the property to its default value.
inherit - It is used to inherit the property from its parent element.
Width property
It does not include padding borders or margins. It sets width of the area inside the padding, border, and margin of the element.Syntax : width : auto | length | initial | inherit;
Property Values :
auto - It is a default value. it is used to calculate the width.
length - It is used to define the width in px, cm etc.
% - It defines the width of the containing block in %.
initial - It is used to set the property to its default value.
inherit - It is used to inherit the property from its parent element.
Example:
Output:
![](pic2.png)
The height and width of 150px.
![](pic2.png)
The height and width of 100px.
Do you Know?
Progamming is what actually means ?What is software development ?
How we categorized software development in different manner.
C Plus Plus
Python
Java Development
Web Designing
Javascript
Mysql
Oracle