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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With