homepage Welcome to WebmasterWorld Guest from 23.20.91.134
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / WebmasterWorld / New To Web Development
Forum Library, Charter, Moderators: brotherhood of lan & mack

New To Web Development Forum

    
Div, div, div, div
Using div all over for CSS?
Bucephalus




msg:4039455
 1:51 pm on Dec 8, 2009 (gmt 0)

Well, I'm sure I was reading somewhere on this site in some forum how it is easy to fall into the trap of "overdiving". I'm doing a dreamweaver tutorial that uses divs for different sections of the page and it seems to work very well.

It seems to me div is good for laying out a site. Are there reasons why we shouldn't do this, or more appropriate alternatives?

David.

 

piatkow




msg:4039534
 4:49 pm on Dec 8, 2009 (gmt 0)

The divs that you NEED for layout are good. Slapping an extra pair around every paragraph where there is no change in the layout is not.

rocknbil




msg:4039848
 3:41 am on Dec 9, 2009 (gmt 0)

Are there reasons why we shouldn't do this, or more appropriate alternatives?

If your goal is presentation only, no.

If you want to create a "smart" document, one where the elements you use appropriately describe the content, then this is a very good reason not to use divs - except where appropriate. We want to do this so that machines and devices that cannot interpret context of anonymous text can get some clues from the markup. For most of us, this means search engine spiders, but other devices benefit from this as well.

<h1> is a page heading. <p> is a paragraph. <span> spans text. You see where it's going . . . a div is a generic container used to divide a page and it's purpose is to manipulate a layout. So if it's a container to divide up a page, it's a perfectly legitimate element because you don't want to assign a semantic meaning to these.

A common example, you have a navigation:

<div>Home</div>
<div>About</div>
<div>Contact</div>

But what is a navigation? A list of links:

<ul>
<li>Home</li>
<li>About</li>
<li>Contact</li>
</ul>

It's important to remember you can style any element to imitate the behavior of any other element. You will often see div's "forced" to do a specific task when a paragraph or list will do just as well, and give semantic meaning to the content.

While we're on the topic, a pet peeve of mine,

blah blah blah blah <br><br>
blah blah <br><br>
blah<br><br>

Give your content meaning to machines parsing it.

<p>blah blah blah blah </p>
<p>blah blah </p>
<p>blah</p>
Does it make a difference in presentation? Not likely.

Bucephalus




msg:4041930
 1:24 pm on Dec 12, 2009 (gmt 0)

Thanks for your response.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / WebmasterWorld / New To Web Development
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved