I have a basic question regarding HTML/CSS and the behaviour of margins from certain elements.
To make my point clear, I created this fiddle: http://jsfiddle.net/5VA5h/
You see, I applied some kind of “reset” and added some styles to all h1.
In the first example, the margin from h1 is applied on the outside of the box, while in #c, where h1 is set display: inline;, it is applied inside the box.
Why is this so?
In your first example, with the
<h1>as a block element, the top margin is collapsing (emphasis mine):…and later:
The second example, with the
<h1>as an inline element, the vertical margins do not take effect: