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?
About this post
- Posted
- Archived
- Score
- 6 · 100% up
- Kind
- Text
- ID
- ipiq3
27 comments
This isn't the 90's, jump on board the standards train.
There's nothing to debate. Tables are meant for tabular data. Nothing else.
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.
I can also build an entire site using nothing but <p> tags, doesn't mean I should.
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.
BC tables should only be used to show charts and lists whereas divs are actually meant to be used for design purposes?
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.
I like how there are currently 12 posts in here and 2 have valid 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.
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...
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?
Fuck everything about designing e-mails in HTML.
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.
Tables also create an unnecessary large amount of code. It's not the easiest to navigate through.
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?
If anyone has done an even remotely complex html email layout you will learn to appreciate tables for layout.
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 :).
Deleted before we saved it.
because:
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.
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.
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 advantages using TABLEs for layout:
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
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
http://www.table2css.com/articles/how-convert-manually-your-html-tables-css
Reading through the above link, there's a lot of peculiarities in DIV's and CSS that make converting something that is in a table into the same thing implemented differently.
I thought it would offer convincing arguments, but it doesn't.
http://www.positioniseverything.net/articles/pie-maker/pagemaker_form.php
If one makes a table using the above automated solution - the source code looks hideous!
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.
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.