Should Tables be avoided in HTML at any cost?

http://stackoverflow.com/questions/82391/should-tables-be-avoided-in-html-at-any-cost#82402

——-

It is advisable to use tables in HTML pages (now that we have CSS)?

What are the applications of tables? What features/abilities does tables have that are not in CSS?

——-

I guess I’m not in the majority here, but I still see a lot of use for tables in HTML. Of course, yes, for things like forms, you simply can’t beat a table. Trying to line up the labels and accompanying form fields would certainly be possible using DIV’s, but what a PITA that would be, and resizing the page would be ugly in some cases. A table works wonders here.

But also consider larger issues. For example, have you tried to create a standard 3 column layout with header and footer using only DIV’s and CSS? Again, it is very possible, and there are about 1000 websites with examples, but they all tend to suffer from the same problems. The first problem is that the columns never really like to all become the same height without some sort of javascript assistance. The second problem is changing the layout is often a tricky thing, because it is a bit of a balacing act to get everything “just right” to begin with, so then you don’t want to mess with it. Finally, and this goes back to that last point – it ain’t easy. You have to lay out all your DIV’s, then go back and create the magic CSS that force those DIV’s into the proper position, and then spend a few hours tweaking it until it is right…. ugh. And then looking at the HTML without a viewer really gives you NO idea what the page looks like because it is ALL reinterpreted by the CSS in the end.

Now, option B. Use a table. Spend about 30 seconds typing out the <tr> and <td> tags, probably no CSS at all, no javascript ‘fixit’, and know EXACTLY what it will look like just by looking at the HTML.

Certainly there are arguments for and against tables, and purists seem to favor DIV’s for layout, but don’t use DIV’s for religious reasons just because someone told you tables are evil. Use what works best for you, your page, and the way your viewers are going to interact with the page. If that’s a table, then use it. If not, don’t.

댓글 남기기

이메일은 공개되지 않습니다. 필수 입력창은 * 로 표시되어 있습니다