Is it good to use tables in HTML 5?

According to the specifications, <table> represents data with more than one dimension and "must not be used as layout aids."

If you need to display tabular data with more than one dimension, then you should definitely use a table. If you just need columns, don't. There are many CSS frameworks out there like bootstrap that can simplify the styles you need to build a grid.


Simple rule - Use tables for tabular data, use other elements for presentation(designing layouts using css) like div, section, aside, nav etc . which provides meaning to the content they hold rather than using table for everything

The fact is, developers used tables in 90s for drafting their layouts, but now, new CSS3 spec is amazing, it gives you so much hold on designing layouts like Flex Box, column-count, behavior of the box model can be altered by using box-sizing property, responsive designs are getting better and better using @media queries, grids etc., which you cannot achieve with table element... and hence, table is only used for storing tabular data.

I've seen many developers having an impression that table should be completely ignored, and instead they use a whole lot of div with 100 lines of CSS, applying display: table; table-cell table-row properties just to get a single table straight.

So even in HTML5 it is COMPLETELY OK if you use tables for tabular data.


From W3 Org : (v4.01)

Tables should not be used purely as a means to layout document content as this may present problems when rendering to non-visual media. Additionally, when used with graphics, these tables may force users to scroll horizontally to view a table designed on a system with a larger display. To minimize these problems, authors should use style sheets to control layout rather than tables.


From (HTML 5)

Tables should not be used as layout aids. Historically, many Web authors have tables in HTML as a way to control their page layout making it difficult to extract tabular data from such documents. In particular, users of accessibility tools, like screen readers, are likely to find it very difficult to navigate pages with tables used for layout. If a table is to be used for layout it must be marked with the attribute role="presentation" for a user agent to properly represent the table to an assistive technology and to properly convey the intent of the author to tools that wish to extract tabular data from the document.

There are a variety of alternatives to using HTML tables for layout, primarily using CSS positioning and the CSS table model. [CSS]

Tags:

Html