You are here: Re: Paragraph and DIV usage in XHTML « HTML « IT news, forums, messages
Re: Paragraph and DIV usage in XHTML

Posted by Andy Dingley on 10/24/06 15:46

tzuchia16@yahoo.com wrote:

> I'd like anyone's thoughts on which of the following would be the
> correct manner of coding for XHTML.

> <div class="spacer">&nbsp;</div>

All the others are varying degrees of wrong.


It's not a paragraph if it's only there as a "spacer", so it's just an
anonymous block element or <div> rather than <p>.

Only <p></p> / <div></div> style meets the Appendix C recommendation on
back-compatibility for SGML / HTML parsing of non-empty elements.
Anything else is very wrong.

If it's a "spacer" rather than having some content, then it should have
a class on it and not be merely anonymous.

If it's empty, then put a space in there at least or you can get
problems with it sometimes being discarded or re-serialized as "<div
/>"


PS - I'm also suspicious that you should be doing this at all. If the
"spacer" is to have an image in it or even some background colour /
borders, then it's reasonable. If it's truly just an invisible spacer,
then you should probably be using CSS instead. In particular your
comment "it's smaller than paragraph tag" makes me suspect that you
should be doing all of this with CSS and not adding any markup to your
HTML at all.


PPS - Don't use XHTML, use HTML 4.01 Strict instead.

 

Navigation:

[Reply to this 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

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