Skip to content

Opening the html table debate

I meant to paste in a section of "divs" from google, but it was too long for reddits text (max 10000) I make everything in tables, its pixel perfect and works in all browsers. This is frowned upon by most of the internet community. why? what benefit do divs offer over tables?

6 points26 comments
Open on Reddit
About this post
Posted
Archived
Score
6 · 100% up
Kind
Text
ID
ipiq3

Author

7
posts
2
comments
0
media
View profile

27 comments

There's nothing to debate. Tables are meant for tabular data. Nothing else.

7 points

Doing the whole page as a huge jpg, then using imagemaps for links is also pixelperfect and works on everything.

Tables have similar problems like the imagemap. It is harder to support, you may face problems or unnecessary extra work when you add extra content or update the design.

6 points

I can also build an entire site using nothing but <p> tags, doesn't mean I should.

6 points

As it stands this isn't a 'debate' worth having, as it's been settled for many years now. But I'll do my best to explain why.

The central purpose of HTML is to provide a set of semantic elements through which you can construct a webpage, tables were used (wrongly) for this purpose for a long time because HTML's counterpart standard CSS wasn't widely enough adopted to allow an alternative. It was used out of necessity rather than by it's own design or core purpose.

Now that CSS is supported in all major browsers (and has been for many years) there is now no need to wrongly use tables for purely presentational or structural markup. Tables do have a purpose however, they should be used to display tabular data.

There is no design or feature which you (or anyone else) can create using tables that I (or anyone else) couldn't create using proper semantic markup. There is also no browser that would render my design in any way 'worse' than yours, unless we're talking the <0.1% of users still using IE 5.5, and frankly they go fuck themselves with a rake.

In fact, several modern mobile browsers have major performance issues with rendering large quantities of tabular data. So in fact, your table based markup renders worse in some cases than the modern semantic markup that most developers now produce.

6 points

BC tables should only be used to show charts and lists whereas divs are actually meant to be used for design purposes?

5 points

I switched over from tables to DIVs...its soo much better and easier. Takes a lot less code, is more customizable, and I could go on...

It might be challenging at first...but believe me, DIVs are much much better than tables. Invest the time to learn everything DIVs can do, and you will kick yourself for not learning it sooner.

4 points

So what happens when someone opens your table layout website on a mobile device?

The reason for using proper markup for layout elements is so you can prepare for and code for different screen widths and capabilities. You can use tables all you want, just don't use them for layout. Use them to display tabular data.

3 points

because thou shalt not include presentational information in your markup. Or at least, that's what the holy commandments say.

One day you will be able to use display:table-cell etc. consistently in all browsers, and do exactly the same thing, except that instead that <table> you will write <div>.

So, at the end, the original sin of <table> &c is just that they have insultingly explicit names.

p.s. and please, don't try to convince me that floats are a wonderful, well-thought tool for layout...

3 points

You can still write HTML emails this way, it's preferred and the only cross-client method that's consistent. Perhaps your calling is an HTML email designer/dev?

2 points

I haven't checked how modern browsers work but it used to be that all data and all elements contained in table had to be loaded before table could be rendered. No progressive rendering with tables. When connection was dropped in mid-loading or you just had slow connection and canceled loading nothing was rendered on screen when table had not finished loading. Huge pain in the arse it used to be.

2 points

Tables also create an unnecessary large amount of code. It's not the easiest to navigate through.

2 points

You can still write HTML emails this way, it's preferred and the only cross-client method that's consistent. Perhaps your calling is an HTML email designer/dev?

2 points

If anyone has done an even remotely complex html email layout you will learn to appreciate tables for layout.

2 points

divs = division (of a page) table = table.

markup code is meant for markup, You can use tables for design. And there is a place for tables, like email newsletters because Outlook is a crippled boy who doesn't play well with others.

You can check this article from a list a part: 12 Lessons for Those Afraid of CSS and Standards

We can only tell you that it is easier for us to use divs instead of tables. I'm not trying to convince you, just showing you how this helped me enjoy the html authoring part a lot more than with tables.

To me it makes more sense to call something that looks like a table a 'table', and something that looks like a division a 'div', that's what it means to me to be 'semantic'.

I started out using frontpage, then dreamweaver, switched to plain notepad, now i do all my code by hand on either notepad++ and VIM.

I feel a progression from just html I threw together 7 years ago, to tables to xhtml and html5 I do now, I don't claim I know why modern standards html is better than tables, but I do know that I feel it is more useful to me because it generates less code and calls things semantically. Good luck on your search, I'm pretty sure that there are a lot of resources in research as to why modern html is better than table layouts.

I do have a similar feeling towards compiled css using tools like Compass and Sass as opposed to generating the css yourself, I feel that they are unnecessary, convoluted and they try to make css something it is not. Seems to me that it came out of the premise that css was hard to do, while in reality i think its pretty straight forward, the people I know that are using those tools are primarily programmers and not html coders, but anyway, that's another story :).

2 points
unknown author

Deleted before we saved it.

1 points

because:

headline
    introintrointroi
    introintrointroi
    introintrointroi
    introintrointroi
    subhead
        copycopycopy
        copycopycopy
        copycopycopy

        picpicpicpic
        captioncapti

        copycopycopy
        copycopycopy
        copycopycopy

    subhead
        copycopycopy
        copycopycopy
        copycopycopy

        footnotefoot
        footnotefoot

is better described through nested elements than chopped indiscriminately into unrelated pigeonholes.

try to view your sliced and diced content in readability and check how it mangles your content.

1 points

One reason is because it can be incredibly difficult to make a layout change. Other elements can be tweaked individually, but moving a cell in a table requires altering the entire table.

But if you're down with that who cares.

1 points

I was an all TABLEs kind of guy... then I was an all DIVs kind of guy... now i'm a "use semantic elements and only use non semantic elements like TABLESs when necessary" ...

Some problems using TABLEs for layout:

  • Some programs/robots (e.g., screen readers, search engine crawlers, browser plugins, facebookexternalhit robot, etc) reading the HTML may be confused on how to interpret the content... It may think that the content in two <tr>s are logically seperate in subject matter, but in fact they logically belong in the same subject (e.g., company location)... since TABLEs represent tabular data semantically, programs should treat the contents as tabular data.
  • More markup causing more DOM elements... causing more memory usage... causing slow page rending... especially if you need to nest TABLEs within TABLEs.

Some advantages using TABLEs for layout:

  • Easy vertically aligning dynamic height content... yes there is display:table-cell; in CSS, but this doesn't work in IE6 or IE7... and yes there are cross browser CSS solutions for this, but require lots of CSS and browser specific CSS
  • Fixes this problem in all browsers: http://stackoverflow.com/questions/485827/css-100-height-with-padding-margin (also fixes the 100% width with padding/margin)

If you are not supporting IE6 and IE7, there is no good reason to use TABLEs for layout.

I've been using TABLEs when I need to make a cross browser flexible form that has text fields nicely arranged, and where the width of the form may vary, and changing dimensions of elements inside of the form doesn't break the nicely arranged fields (or need extra width/height adjustments)... love to see somebody prove to me that this can be done in CSS.

Edit: formatting

1 points

I clicked here thinking "lol, there is no debate, everyone uses divs now". How wrong I was.

divs are also pixel perfect and work in all browsers. If yours don't, you're clearly doing it wrong. Which is, honestly, pretty difficult to do, since you can just copy/paste a div implementation from someone who isn't doing it wrong.

Oh, just read this:

http://www.hotdesign.com/seybold/everything.html

1 points

Along with what everybody has said about standards, ease of change, etc....

SEO. Guess what Google's engine searches for first... stuff in DIVs! AFAIK it does not do a whole lot with data in tables.

1 points

Why?

Less code.

Easier to change in significant ways.

Search engines have specialized algorithms to identify tables and extract tabular data. Using tables for data fucks this up. Thanks for screwing up the internets.

1 points

Keyboard shortcuts

Move and act

jork
Next / previous post or comment
Enteroro
Open the post
f
Open the media viewer
s
Save
h
Hide (the toast has Undo)
Tab
Right after an action: the toast's Undo
x
Collapse the comment
v
Next layout: cards, compact, grid

Go to

/
Search
gthenh
Home
gthena
All
gthens
Subreddits
gthenl
Library
?
This list
Esc
Close a menu or this list

In the viewer

←or→
Previous / next file
↑or↓
Previous / next post
korj
Previous / next post
Space
Play / pause
m
Mute
z
Zoom
s
Save
o
Open the post (on its own page: back to it)
Esc
Close

Keys do nothing while you type in a box.