4 ms·
HTML tables are not evil. Using them is not a sin. They do not suck.
- lhorie 16y agoSure, until you need to print the page. Or show it on a iPad.
- foljs 16y agoIn both cases, it works just fine. Your point? Fact 1: Tables are not very good web layout tools, and were not invented for the purpose. Fact 2: CSS floats are not very good web layoyt tools. In fact, they are horrible, and were not invented for the purpose either (check the W3C specs). Fact 3: A grid layout approach is the best layout approach we now. We use it in DTP, we use it in most desktop software GUI designers, and we use it when using tables (a table = a poor mans layout grid), and we try to mimic it with horrible hacks when using CSS layouts. Fact 4: The W3C is working on a proper grid based layout method, the CSS3 Grid positioning module ( http://www.w3.org/TR/css3-grid/ http://www.w3.org/TR/css3-grid/ ). Sadly, not quite there yet. People tooting current css floats as the layout method are just ignorant. They are mostly graphic designers that can't see the tradeoffs and inefficiencies of this horrible implementation. And its not just the discrepancies between various browsers (notably, IE) that make it bad. CSS layout / positioning is a true example of design by committee. It makes easy things hard and hard things fragile. Just consider the basic task of centering an item: .this-is-idiotic {margin-left: auto; margin-right: auto;} or the horrible solutions to problems that should non exist anyway, like the equal height column thing (faux-columns? Using a background image? And this is the best solution that the css gurus in "A list apart" can come up with? Really?) Oh, and the lack of proper constants, declaration nesting, and everything else LESS provides. Very good standards work, after 15 years and 3 versions. Oh, and in a language all about one line statements, who had the brilliant idea to only allow /* */ comments?
- tristanperry 16y agoI felt like that when learning XHTML+CSS in the HTML 4 days (when the most common question seemed to be 'Best layout method: iframes or tables?!'), and with IE 5.5 still being used a bit it was a big annoyance to switch over to XHTML and CSS. But honestly, I now couldn't go back. I seldom run into any cross browser issues (apart from the odd IE 6 and 7 issue, which conditional comments takes care of in a minute or two), and I now couldn't imagine using tables for a layout. But you're right that using HTML tables isn't evil. They're designed to display tabulated data and using them for this purpose is definitely a good plan ;-)
- CoreyLoose 16y agoNot going to say I use them all the time but I sure do love me a good table. Just today I had to debug some code that was a css-simulated-table that went all wonky with its floats and clears.
- robwgibbons 16y agoSure, tables are not inherently evil. But like every other HTML element, they have their correct and incorrect uses. The reason you hear so much crap about them is because of very widespread misuse. When used correctly (read: where you need to display tabulated data) tables are perfect. In some cases, they may even be warranted in layout design. However, this is not common. Using DIVs and CSS makes for much cleaner code where a table is not explicitly needed. Hacker News actually uses tables. Not sure why, but maybe there's a good reason.