Hey I am having a problem with understanding a certain aspect of margin within css.
Heres the problem I don't understand:
<style type="text/css">
*{margin:0; padding:0;}
#header {height:100px; background-color:#CCCCCC;}
#header p {margin:10px 0 0 10px;}
</style>
</head>
<body>
<div id="header">
<p>Hello</p>
</div>
What I don't understand is why does applying a margin-top to the <p> making the containing div id="header" jump down 10px on screen but not left 10px - in this case just the text moves.
Why doesn't the text just move with margin-top:10px?
I'm not moving the containing div. I'm telling it to move the <p> no?
I really don't get this.
Thanks, Andy
</body>
</html>
Heres the problem I don't understand:
<style type="text/css">
*{margin:0; padding:0;}
#header {height:100px; background-color:#CCCCCC;}
#header p {margin:10px 0 0 10px;}
</style>
</head>
<body>
<div id="header">
<p>Hello</p>
</div>
What I don't understand is why does applying a margin-top to the <p> making the containing div id="header" jump down 10px on screen but not left 10px - in this case just the text moves.
Why doesn't the text just move with margin-top:10px?
I'm not moving the containing div. I'm telling it to move the <p> no?
I really don't get this.
Thanks, Andy
</body>
</html>