Should Tables be avoided in HTML at any cost?

后端 未结 27 2393
生来不讨喜
生来不讨喜 2020-12-01 01:56

It is advisable to use tables in HTML pages (now that we have CSS)?

What are the applications of tables? What features/abilities does tables have that are not in CSS?

相关标签:
27条回答
  • 2020-12-01 02:29

    Tables make sense only when you're trying to display tabular data and that's it. For layouts, you should always use DIVs and play with CSS positionings.

    0 讨论(0)
  • 2020-12-01 02:29

    if you need to use a table, your layout probably sucks. Show me a single well-designed site that uses tables, and I'll show you a thousand that don't.

    A lot of people are throwing around the term "purist". This is rubbish. Would you print newspaper copy in a book? Would you design a brochure with Excel? No? Then why would you use a table to display non-tabular data?

    Most times the difficulties people face in letting go of tables for layout is a result of their own ignorance of HTML/CSS/Good Design Principles. While you may find it difficult to make multi-column layouts extend evenly in the vertical direction, you might think to try a different method. DIVs are not TABLEs. You can make faux columns using wide borders, page backgrounds, etc. Spend some time actually learning to do what you're setting out to do, or forever be seen as someone without any kind of useful skill. (http://www.alistapart.com would be a good start)

    I'm honestly surprised that this question is cropping up in 2008. DIVs came around when I was in high school. Stop being a noob.

    And as was mentioned above, tables fail hard on mobile devices and screen readers.

    0 讨论(0)
  • 2020-12-01 02:31

    If there is a reason for using a table in a semantic way (for example for showing tabular data) use tables.

    Just use no tables to do layout stuff. There are lot of searchengine und accessibility benefits that you get with semantic markup.

    0 讨论(0)
  • 2020-12-01 02:31

    It's easy. Think your webpage as a real page on paper. You should use tables on webpage only when you would draw a table on your paper.

    Another tip is to use table only with border > 0. This way, you use tables only when you mean you want a table (and not for layout).

    0 讨论(0)
  • 2020-12-01 02:33

    @toddhd, advocating the use of tables for layout simply to save time is a cop out. If time is the issue, then you can quickly create a columnar layout without tables using a framework like Blueprint CSS or 960 Grid.

    0 讨论(0)
  • 2020-12-01 02:34

    I am going to assume that your question is actually - "Should I avoid using HTML tables for layout purposes?". The answer is: No. In fact, tables are specifically meant to be used to control layout. The drawback for using tables to control the layout of an entire page is that the source file rapidly becomes difficult to manually understand and edit. A (possible) advantage of using tables to control the entire layout is if there are specific concerns about cross-browser compatibility and rendering. I prefer to work directly with the HTML source file, and for me using CSS makes that easier than using tables for the entire layout.

    0 讨论(0)
提交回复
热议问题