3 ms·
Why is the use of tables considered poor practice? [Edit]: And what then is the most optimal method to use instead of tables?
by Paul_D_Santana 13y ago
Why is the use of tables considered poor practice?
[Edit]: And what then is the most optimal method to use instead of tables?
- jdwissler 13y agoIn my own experience I find them to be very inflexible and unpredictable. There are still scenarios when you need them though, so I wouldn't call them 'poor practice' so much as something that should only be used if it makes sense.
- Paul_D_Santana 13y agoWhat is the most optimal method to use instead of tables? [Edit] Added to my original post.
- jdwissler 13y agoIt really depends on what you are trying to do, I don't really know how to answer the question, it is too broad. But like I said, I don't think tables are 'bad'. I think the main stigma against tables was that back in the old days they were used to layout pages that had column layouts, but I didn't program back then so I don't really know.
- lowboy 13y agoUsing tables for layout is bad, full stop, no quotes. Tables for tabular data are the only reason you should use the <table> element.
- jdwissler 13y agoWhat qualifies tabular data? GMail uses a table for laying out emails, is that tabular? (Maybe it is, I don't know, which is why I'm asking.) What if you have an element which has 5 children that are in a row and you want the one in the middle to take up all the remaining width while the rest just take the width they need? I'm actually curious because I haven't figured it out. (Besides using table cells that is)
- lowboy 13y agoIt's tricky to define exactly, but I like this article's take on it: http://webdesign.about.com/od/tables/a/aa122605.htm http://webdesign.about.com/od/tables/a/aa122605.htm A list of emails can be thought of as tabular data. In Gmail, you have columns (selection, star, important, participants, subject, and date) with one row per email. That's a table without explicit headers. Yeah, with current css specs in browsers you need to resort to table-cell stylings like display:table-row and display:table-cell. But that can be done without using actual <table> elements.
- jdwissler 13y agoI see. I don't think we actually disagree on anything, but were just thinking of different semantics. I should have qualified that I rarely use the table tag and use display:table-cell. I was thinking of them as effectively the same as using a table for layout.
- daemonl 13y agoShhh, you're not allowed to ask that.
- mortenjorck 13y agoThere's nothing wrong at all with using tables when your content is tabular data. The problem is mostly an historical one, dating to before the widespread adoption of CSS: Tables were once the only reliable way to get any sort of layout structure on a page, and so were hacked to accommodate all sorts of layouts through clever use of colspans and rowspans. This was terribly inefficient, but before we had positionable divs, they were the only game in town.
- jakub_g 13y agohttp://stackoverflow.com/questions/83073/why-not-use-tables-for-layout-in-html http://stackoverflow.com/questions/83073/why-not-use-tables-... http://phrogz.net/css/WhyTablesAreBadForLayout.html http://phrogz.net/css/WhyTablesAreBadForLayout.html
- lancedouglas 13y agoTables are a tool. I think that most agree that it is best used for grid/tabular data representation. Tables are similar to a club (caveman-style), it performs best at a particular task, such as knocking-off dinos, but it was quite often used as a hammer, paper-weight, table-leg, etc. Once specific and readily available tools came about, the club's value as a club didn't diminish, just its extended usability did. CSS provided programmers the ability to not use a club as a wrench, but there will always remain a value for tables until something more efficient and effective comes about for the task that they serve.
- ics 13y agoDivs are a like a club too, except the dinos are extinct and so they're expected to be generic. Maybe I'm just feeling nostalgic for something that doesn't exist, but even when looking at clean, clever, or well-architected markup I can't help but think it could be much better.