Skip to content Skip to sidebar Skip to footer

Why Use Anything But Div?

In HTML/XHTML, why use anything other than div elements? They are basic blocks that one can use to build entire pages. Sure, they don't add to the semantics of the page, but HTML i

Solution 1:

Not all elements should be block level elements and the need to specify what kind of element a div is for every div on your page is ridiculous. It is also easier to read.

Solution 2:

Two important reasons:

  1. Search engines
  2. Screen readers

Search engines rank pages based on their content and also the semantics of that content. Adding the proper semantics to your content reinforces the intent of what the content is trying to communicate and that allows search engines to place higher value on that content.

Screen readers also rely on semantically-correct content. See this article for more information.

Solution 3:

Plus how your page is structured says a lot about what is on your page. Search engines will place higher importance on h1 than it will h6. It does more that display your data, it describes your data as well. HTML5 will have even more elements, so you better buckle up.

Solution 4:

Various email clients support differing subsets of HTML that frequently ignore external stylesheets, floats and so forth. In many cases, you'll have to revert to tables.

Solution 5:

Just look at a simple example of what your suggesting:

<div>
    <div>Hello</div>
    <div>this is a paragraph which contains some <div>stuff</div> that should not be in adiv</div>
</div>

Now, is that easier for humans, browsers, search engines, etc.. to understand then the following?

<div>
    <h1>Hello</h1>
    <p>this is a paragraph which contains some <span>stuff</span> that should not be in adiv</p>
</div>

There are different elements for a reason. Outside of being block and inline for style, the tags add a lot of information to a page which is lost if its all replaced with div tags.

Post a Comment for "Why Use Anything But Div?"