Setting height and width Explain
The height and width properties are used to set the height and width of an element.
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.
Note: The height and width properties do not include padding, borders, or margins; they set the height/width of the area inside the padding, border, and margin of the element!
The following example shows a <div> element with a height of 100 pixels and a width of 500 pixels:
height and width properties are used to set the height and width of an element.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.height and width properties do not include padding, borders, or margins; they set the height/width of the area inside the padding, border, and margin of the element!<div> element with a height of 100 pixels and a width of 500 pixels:Html Code:
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 500px;
height: 100px;
border: 3px solid #73AD21;
}
</style>
</head>
<body>
<h2>Set height and width of an Element:</h2>
<div>
This div element has a height of 100px and a width of 500px.
</div>
</body>
</html>


Post a Comment