Hi,
I can't understand how manage the body tag. I wrote this below and to avoid a "white" space between the body tag and the top edge, I had to use margin:-top: -10px; Is it normal?
Moreover, it seems that changing the margin-top of block1, it moves down the entire 'body'. So why can't set e.g. to '10' the margin of 'block1' ?
I can't understand how manage the body tag. I wrote this below and to avoid a "white" space between the body tag and the top edge, I had to use margin:-top: -10px; Is it normal?
Moreover, it seems that changing the margin-top of block1, it moves down the entire 'body'. So why can't set e.g. to '10' the margin of 'block1' ?
Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>1 - positioning</title> <style type="text/css"> html {background: white; } body { background: gray; width: 400px; margin: 0px; padding: 0px; margin-top: -10px; height: 400px } #block1 { background: pink; display: block; border: Dashed 2px; width: 80px; height: 80px; margin: 20px; } #block2 { background: yellow; display: block; border: Dashed 1px; width: 80px; height: 80px; } #block3 { background: green; display: block; border: Dashed 1px; width: 80px; height: 80px; } #wrapper { background: red; position: relative; top: 50px; left: 50px; width: 300px; height: 300px; } </style> </head> <body> <div id="wrapper"> <div id="block1"> Block1 </div> <div id="block2"> Block2 </div> <div id="block3"> Block3 </div> </div> </body> </html>
Comment