Open In App

CSS height Property

The height property is used to set the height of an element. The height property does not contain padding and margin and border of the element. 

Syntax:  



height: auto|length|initial|inherit;

Default Value: auto 

Property Values: 



Example: In this example, we are using height: auto;




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS height Property
    </title>
 
    <style>
        .Geeks {
            height: auto;
            color: white;
            font-size: 30px;
            background-color: green;
        }
    </style>
</head>
 
<body>
    <h2>CSS height Property</h2>
 
    <div class="Geeks">
        GeeksforGeeks: A computer science portal
    </div>
</body>
</html>

Output: 

Example: In this example, we are using height: length; property.




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS height Property
    </title>
 
    <style>
        .Geeks {
            height: 100px;
            color: white;
            font-size: 30px;
            background-color: green;
        }
    </style>
</head>
 
<body>
    <h2>CSS height Property</h2>
 
    <div class="Geeks">
        GeeksforGeeks: A computer science portal
    </div>
</body>
</html>

Output: 

Example: In this example, we are using height: initial; property.




<!DOCTYPE html>
<html>
<head>
    <title>
        CSS height Property
    </title>
 
    <style>
        .Geeks {
            height: initial;
            color: white;
            font-size: 30px;
            background-color: green;
        }
    </style>
</head>
 
<body>
    <h2>CSS height Property</h2>
 
    <div class="Geeks">
        GeeksforGeeks: A computer science portal
    </div>
</body>
</html>

Output: 

Supported Browsers: The browser supported by height property are listed below:  


Article Tags :