|
Posted by Steve Pugh on 05/03/06 23:16
sachaburnett@yahoo.com wrote:
>I've been searching the Net for an explanation of the DIV versus SPAN
>issue but can't get a clear answer. I understand the DIV is
>block-level whereas SPAN is inline, but is it possible to nest SPAN
>tags?
Yes. See http://www.w3.org/TR/html401/struct/global.html#edef-SPAN
<!ELEMENT SPAN - - (%inline;)* -- generic language/style
container -->
The (%inline;)* means that the content of span can be any number of
inline elements. And %inline is defined as <!ENTITY % inline "#PCDATA
| %fontstyle; | %phrase; | %special; | %formctrl;"> where %special is
it turn defined as <!ENTITY % special "A | IMG | OBJECT | BR | SCRIPT
| MAP | Q | SUB | SUP | SPAN | BDO">
Hence span can contain other spans.
>For example, both result in the same output, but which is technically
>correct:
One of them validates, the other one doesn't. A few seconds with the
validator <http://validator.w3.org/> would have told you which.
>USING SPAN
><span class="mainText">
>
><p>Blah blah <span class="blueText">blah</span> blah blah blah blah
>blah blah blah blah blah blah blah blah blah blah blah blah.</p>
>
><p>Blah blah blah blah <span class="redText">blah blah </span> blah
>blah blah blah blah blah blah blah blah blah blah blah blah blah.</p>
>
></span>
p is not an inline element and hence can not be contained inside a
span. This has nothing to do with nesting spans.
Steve
--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor
Steve Pugh <steve@pugh.net> <http://steve.pugh.net/>
Navigation:
[Reply to this message]
|