Duplicate of:
Theres been a lot of talk lately about rather using div than table tags to make your pages more browser fiendly. Why is div better?
So, when creating a table, all you need to do is, instead of the HTML 'table' tag, merely use the 'div' tag and add the corresponding CSS to display a table. Here's an example to walk you through the process of creating a table.
To make DIVs behave like TABLEs, you have to tell them to behave that way using the display property. The three key values that we'll be using are table , table-row and table-cell . Each element now behaves like it were part of a table. In doing so, it also inherits cell capabilities.
TABLEs are the correct technology for tabular data. DIVs are the correct technology for page layout and defining objects on the page (along with other block-level objects, i.e. heading, paragraphs, ul tags etc.). Use them both and use them well.
You can replace a table cell with another table cell just like any other element: var td = <reference to td element>; var newTd = document.
The key point here is using them for layout. There is nothing wrong with tables for tabular data, mind you. That's what they're for.
But when you are using tables for layout you create a very rigid page structure which doesn't usually play well with differing screen sizes, user agents (think mobile browsers or screen readers for blind people. Especially in the latter case you are destroying any order in which the content should be read to the user). Unfortunately tables are still one of the most robust mechanisms to lay out a page, since there are hardly differing implementations and they work for over a decade flawlessly—CSS is an entirely different matter here.
But basically it comes down to this:
<div>
and <span>
. There are many tags that have a meaning and should be used as such. For example, don't use <div class="heading1">
when you could use <h1>
.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