Reply to Re: DIV vs SPAN

Your name:

Reply:


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/>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация