Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use HTML table layout or the new CSS display:table-cell code?

I've used tables but never used the CSS way of doing things. Now I have a table of data with 3 rows and 2 columns. Can someone please explain how I can do this with CSS DIVs and also most important is I would like to know if CSS is the way to do this and what are the limitations.

like image 779
May Avatar asked May 24 '11 19:05

May


People also ask

Why is it not recommended for HTML tables to be used for layout purposes?

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.

Should you still use HTML tables?

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.

What is the advantage of using tables in CSS compared to using tables in HTML?

By using CSS style sheets it is extremely easy to maintain visual consistency throughout your website. When using table based layouts, it is easy to lose this consistency because each web page's style, layout, and design are frequently hard-coded individually into every page.

What does display table cell do in CSS?

Setting display to table makes the element behave like a table. So you can make a replica of an HTML table without using the table element and corresponding elements such as tr and td . For example, in HTML, you can make a table with the <table> element and also a <div> , or any container of your choice.


1 Answers

Beware of display: table-cell. It doesn't work on the anti-browser (the "browser" whose name must not be spoken).

Also, if you have table data, use tables. Use other tags when they make sense semantically (such as <p> for paragraph, <ol> for ordered lists, etc...), or <div>s for layout.

like image 142
rid Avatar answered Sep 20 '22 18:09

rid