tags:

views:

91

answers:

2

Possible Duplicate:
Why not use tables for layout in HTML?

I have read a lot about "tableless CSS", using CSS to format a page rather than tables. Are tables considered bad? I would think them especially useful for formatting form data (labels and input fields in rows) to maintain a neat look by correctly lining up the input fields. Is there a reason not to use tables?

+1  A: 

Using tables for layout was a revolution for web design, but that was way back when tables were the only possible way of doing any layout at all. Today there are alternatives.

Tables still works for layout, but they are not nearly as powerful as table-less CSS layouts. There are a few things that is easier to accomplish with tables, but there are a lot of things that is very hard or completely impossible to do with tables that is very easy to do with CSS.

Originally tables was only intended for tabular data, i.e. values that you wanted to display in a grid, where the grid adjusts itself to how much content there is. To use tabled for layout you first have to defeat this default behaviour, which of course means some extra code.

Generally table based layouts means more code than non-table based layouts. Also, with non-table based layouts you can put more of the code in cached CSS files, which means even less code in the actual page.

Guffa
+3  A: 

Here's a writeup of some reasons: http://phrogz.net/css/WhyTablesAreBadForLayout.html

I personally think the main reasons why tables for layout are bad are:

1) Being unflexible when you want to redesign / use multiple designs. If you avoid using tables for layout, you should be able to change the design of a site by just changing the CSS. If you use tables, you will probably have to edit the site's HTML when you are moving things around.

2) Being semantically incorrect. Tables are meant for tabular data. If you use them for layout, you are using them in a way they are not originally intended for. This doesn't cause problems for most users, but it's a somewhat bad coding style which can affect some users such as visually impaired people who use screenreader software.

dosendoc