On Mon, 15 Aug 2005 21:42:42 GMT, "ppcguy" <> wrote:
>what's the difference between the two - if any...
Go read the spec (the one and only true spec - and it's free!)
http://www.w3.org/TR/html4/struct/global.html#edef-DIV
The first difference is in their content model - you can put %flow;
elements into a <div> and %inline; elements into a <span>. %flow is
itself defined as the union of both %block; and %inline;
So <span> can only have %inline; "stuff" put into it, %div; can also
have %block; stuff put into it. Read the spec for the full details, but
"inline" means strings of text and those bits of HTML markup that affect
character-level formatting (bold etc.) without affecting linebreaks.
"block" is the other stuff: paragraph and line breaks etc.
There's also a difference in where you can use these two elements. You
can't put a block element inside an inline element, so
<div><span>...</span></div> is OK, but <span><div>...</div></span> is
invalid. In general the appropriate parents are pretty obvious in HTML
- most things are obviously one or the other, but read the spec for the
full details.
As far as their styling goes, then you can apply any CSS you like
equally well to either of them. You can even use display:block; to make
a <span> _look_ like a <div> and vice versa with display:inline;, but
this still won't change the DTD rules about what can go inside what.
--
Cats have nine lives, which is why they rarely post to Usenet.