Posted by: nervous on: November 1, 2006
How many times we’ve heard this phrase: stop using tables for layout, use divs instead
?
This is the most common misleading phrase that can be told to a webdeveloper who still uses tables for layout.
Every standard-semantic acknowledged webdeveloper knows the downside effects of using divs as replacement for tables. Overuse of divs, commonly known as divitis
, results in non-semantic markup as well as that of tables, probably worse.
When you design using tables, you implicitly say that your text or images or whatever you put on your page, is indeed data. This is because tables are meant to contain data. On the other side, divs are meaningless containers that implicitly mean nothing. So whatever you put in a div, is just some unidentified content.
That’s why I think we shall never say that tables can be replaced by divs in order to avoid confusion.
Table layout design, is not only common because of practical reasons, but mostly because very few webdevelopers truly studied HTML during their learning phase, only relying on its relative ease of use and on tag soup
parser’s leniency (without even knowing they were exploiting it).
Ignorance of the meaning of each HTML tag together with the wrong attitude of exploiting tags presentational defaults values, gave us this legacy of br’s used to space blocks of text in table cells or whole tables and so on.
If we replace tables with divs, but we keep using divs the same way we used tables, semantic is still a mirage.
So divs, in the new course of correct, semantic markup, shall be used only when proper HTML tags cannot be directly addressed with style, or when several tags need to be grouped together. In addition to that, divs can be used, together with semantically wise ids and classes, when a proper HTML tag does not exist for the purpose.
Same thing when you hear someone saying that he wants to switch from a table based layout to CSS. Pretty much as saying you want to change your car’s (crappy) engine and chassis with a new colorful paint.
What webdevelopers should do to leave the dark side of tables layout and, more in general, of ignorant web-making, is to study HTML tags one by one, thoroughly, and reading and watching around how renowned webdevelopers use those tags in their websites. Once they have a proper understanding of the use of HTML tags, semantic and its uncountable advantages will pretty much come along straightforward.
There is nothing new in this brief post, and I certainly didn’t go too deep into the problem. Tons of similar information are available in the net, but according to many of my favorite authors, still not enough. I agree with that, and little by little, I will give my contribution.
[...] I read this Plus I’m a noob, so I ain’t that good with DIVs yet…. Though I’ll give it a [...]
Wise up, you don’t have a clue what your on about! Using css (divs) allows for accessibility issues where using tables don’t, never mind the extra loading times ect!!! Read up at a list apart and many other sites online!!
Using tables for layout is bad practice. I have read the article and from my understanding what you are saying is using divs and css is no better than using a table?
Like any HTML tag the table has a particular use, which is displaying tabular data like league tables or something similar. It was not designed or intended for layout purposes.
If you are really interested then there are countless articles on the web just look up the benefits of CSS over table-based design.
ps this and all wordpress themes use css to the best of my knowledge.
OK, you’re absolutely right that many people just replace tables with divs and their code isn’t much better.
This is a big problem and exactly why I cringe whenever I hear “don’t use tables, use divs”.
Everyone should be using semantic HTML and CSS. Use a div where you have a structural DIVision in the page (sidebars, banners, footers, etc). This is what needs to be explained – use of divs in a similar way to the use of fieldsets in forms (meaningful, structural division of elements).
But we should encourage people to not use tables for layout everywhere and at all times. In fact, anyone still using tables for layout in 2008 needs to look into a new line of work.
Your article does sort of read (at first at least) like “go ahead and use tables, they’re fine”. They’re not – unless you’re marking up tabular data.
March 6, 2007 at 5:50 pm
Nice
i totally agree