You are here: Re: DIV vs SPAN « HTML « IT news, forums, messages
Re: DIV vs SPAN

Posted by Steve Pugh on 05/04/06 20:51

sachaburnett@yahoo.com wrote:

>Along the same note... I've read that nesting DIVs is a bad practice.
>True or false?

Depends. There's what's called 'div soup' where the page consists of
almost nothing but divs. That should be avoided.

Start by marking up your content as headings, lists, paragraphs, etc.
Then add divs to group these together into logical and useful
divisions. You may find that some of these divisions are natural
children of others.

>Is there anything wrong with the following code:
>
><div id="layoutPage"> <!-- This is to format the page's layout -->
>
><div class="mainText"> <!-- This is to format a block of text -->
>
><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>
>
></div>
></div>

There's nothing technically wrong with it.

But if that's the whole code then the two divs can be combined.
However, most likely you'll have other things inside the layoutPage
div as well as the mainText div.

And think about using more logical and less presentation orientated
class and id names. class="blueText" is silly if next week you change
the design and end up with .blueText {color: red;}
Ask yourself, why is that text blue? If it's for emphasis then
consider using em or strong instead of span, and then maybe you won't
need a class name at all.

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]


Удаленная работа для программистов  •  Как заработать на 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

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