Tuesday, December 05, 2006

When div when span

DIV is an arbitrary *block* element. It can contain other block
elements (including other DIVs). P is block element for
paragraphs. P cannot contain other block elements; it cannot
contain other Ps; it cannot contain DIVs. DIV does not create a
new P. But DIV will close any P that is open.
[color=blue]
> I tend to use SPAN because it does not generate any line break.[/color]

SPAN is an *inline* element. It cannot contain a block element.
SPAN is closed whenever the block containing it is closed.

No comments: