Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should Tables be avoided in HTML at any cost?

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?

Related Questions

  • Tables instead of DIVs
  • DIV vs TABLE
    • DIVs vs. TABLEs a rebuttal please
like image 446
Niyaz Avatar asked Sep 17 '08 12:09

Niyaz


People also ask

Should I avoid HTML table?

The HTML 4 specification states: "Tables should not be used purely as a means to layout document content as this may present problems when rendering to non-visual media." So, if you want to write valid HTML 4.01, you can't use tables for layout.

When should tables be used in HTML?

HTML tables should be used for tabular data — this is what they are designed for. Unfortunately, a lot of people used to use HTML tables to lay out web pages, e.g. one row to contain the header, one row to contain the content columns, one row to contain the footer, etc.

Are HTML tables outdated?

While the <table> element is not deprecated, using them for layout is strongly discouraged. In fact, pretty much all HTML table attributes that were used for layouts have been deprecated, such as cellpadding , bgcolor and width .

What are the advantages and disadvantages of using tables in HTML?

Advantages: great for displaying tabular data on the Web. Disadvantages: some folks still use them for other tasks like handling layouts. which you shouldn't be done unless you've travelled back in time to the 90-s and need to build a website. If it's not the case, don't use tables for anything but tables.


2 Answers

No - not at all. But use tables for tabular data. Just don't use them for general layouting.

But if you display tabular data, like results or maybe even a form, go ahead and use tables!

like image 150
Mo. Avatar answered Sep 21 '22 15:09

Mo.


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.

like image 45
Todd Davis Avatar answered Sep 20 '22 15:09

Todd Davis