Hi,
I am a bit confused about the height behaviour of DIV elements. In particular, if I give a div a border it will include the padding of anything inside it when deciding the height. If I use no border the padding is not included in the height. This is very obvious if you color the background of the div.
Is this the correct behaviour? Can someone point me to where it is described on w3? Also any recommendations for books that really cover css well would be appreciated.
Many thanks,
Alex.
I am a bit confused about the height behaviour of DIV elements. In particular, if I give a div a border it will include the padding of anything inside it when deciding the height. If I use no border the padding is not included in the height. This is very obvious if you color the background of the div.
Is this the correct behaviour? Can someone point me to where it is described on w3? Also any recommendations for books that really cover css well would be appreciated.
Many thanks,
Alex.
Code:
<!DOCTYPE HTML>
<html>
<head>
<style>
.div1
{
background: blue;
width: 200px;
}
.div2
{
background: blue;
width: 200px;
border: 1px solid black;
}
</style>
</head>
<body>
<div class="div1">
<p>Hello</p>
</div>
<div class="div2">
<p>World</p>
</div>
</body>
</html>
Comment