Welcome to WebmasterWorld Guest from 126.96.36.199
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?
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:
But what is a navigation? A list of links:
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>
Give your content meaning to machines parsing it.
<p>blah blah blah blah </p>
<p>blah blah </p>
Does it make a difference in presentation? Not likely.