Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it good to use tables in HTML 5? [closed]

Tags:

html

I need to display post and related data in column-wise grid and certainly require table for those as aligning divs in single line, using floats is a time consuming thing!

Will appreciate your reviews on Do's and Don't for Tables in HTML5!

like image 438
Dangling Cruze Avatar asked Jul 06 '13 13:07

Dangling Cruze


People also ask

Should I still use tables in HTML?

You should only use tables for tabular data, and tabular data generally looks like something you might display in a spreadsheet or possibly a database. However, HTML5 changed the rules and now tables for layout, while not recommended, are considered valid HTML.

Why tables are not good in HTML?

HTML tables were originally intended to be used for presenting tabular data, not for layout. The World Wide Web Consortium (W3C®) discourages use of tables for layout because they are striving for a web in which content and structure are completely separate from presentation.

Are tables deprecated in HTML5?

table tag isn't deprecated (you can look at the html spec). What you've heard of is probably tableless layouts, because tables should not be used for positioning elements on the page.


1 Answers

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]

like image 68
Mr. Alien Avatar answered Sep 23 '22 01:09

Mr. Alien