CSS Height/ Width

Unique beauty

➡CSS Height/ Width:

Height and Width in CSS are used to set the height and width of boxes. Its value can be set using length, percentage, or auto.



⇒CSS height and width Examples: 

Set the height and width of a <div> element: div { height: 200px; width: 50%; ...

Set the height and width of another <div> element: div { height: 100px; width: 500px; ...

This <div> element has a height of 100 pixels and a max-width of 500 pixels: div { max-width: 500px; height: 100px;


Example: 


<!DOCTYPE html>
<html>
 
<head>
    <title>width and height</title>
    <style>
        .GFG {
            height: 120px;
            width: 50%;
            border: 5px solid black;
            padding-left: 50px;
            padding-top: 50px;
            font-size: 42px;
            font-weight: bold;
            color: green;
            margin-left: 50px;
            margin-top: 50px;
        }
    </style>
</head>
 
<body>
    <div class="GFG"> Hii unique pooja</div>
</body>
 
</html>

Output:

            

              Hii unique pooja






Our website uses cookies to enhance your experience. Learn More
Accept !

GocourseAI

close
send