Jeff Thies wrote
rf wrote:
Well, I thought that this was wrong, and this is what I meant:
p{display: inline; height: 100px; margin-top: 20px}
Having block level properties for a block element that have been inlined.
oddly, I know this is legal:
Correct, it's legal but section 10.6.1 of the CSS 2.1 spec states that the
height doesn't apply. Further (this particular section is not very well
written) vertical padding, border and margin do not affect the spacing of
the element, only the line-height is used.
A telling test is to tip this into your browser:
span {border: solid 1px green; padding: 4px;}
<span>a lot of text to make the span flow onto more than one line on the
canvas and thus generate two or more line boxes</span>
http://users.bigpond.net.au/rf/t.htm
(I've thrown in margin: 20px; here to show what happens with the margins.
Not quite what you expected ?)
You will see that each of the line boxes (refer to section 9.4.2) is one
line-height high plus 10 (in this case, 8 for padding and two for the
borders) pixels however the line box vertical *spacing* or *layout* is one
line-height, the height of the content.
The line boxes actually overlap and their borders end up intertwined. They
even escape outside that enclosing red div
This is why if you throw a margin and some padding into an <a> to make it
look like a pretty button you usually have to fiddle with line-height as
well. Of course you must specify line-height in ems or things will screw up
when your viewer changes her font size.
The top and bottom margins are "ignored" in that they only ever affect
positioning of elements and vertical position for inline elements is based
on line-height only. It's probably kept floating around in the DOM somewhere
but it doesn't do anything.
Sometime my head just spins hacking throug CSS!
You have to read the spec. Then you have to read it again. Then you have to
have somebody explain each bit to you. Then you have to go away for a quiet
week at the snow/beach/pub to get ready for another read of the spec.
After a year or two a couple of facts will sink in. Most notably the fact
that the spec itself is not very well written. Vital bits (like what happens
to the top margin of an inline element) are sort of glossed over or
mentioned in passing or, more often, implied by the *lack* of comment about
them. This probably stems from the fact that the spec was originally written
partly to describe what the then current browsers actually did. It also
causes lots of arguments in usenet on the correct interpretation of a
particular paragraph