Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: HTML
Why is DIV better than TABLE?
 
I am very old and have used tables for yonks, but was told off recently.
Just wondering the reason why.
Posted 12-Apr-10 1:11am
Dalek Dave432.9K
Edited 12-Apr-10 1:36am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

A lot of it depends on whether or not you want to reposition items; also, do you want your items to be able to be read using a screen reader. Screen readers generally have a terrible time with tables because they can end up reading things out of the order you intend them to be.
 
It all boils down to, use the tool that's appropriate for the job. If you want to display data as in a spreadsheet, use a table - positioning divs to do this is just a nonsense. If you want to reposition content or have a site that is more SEO friendly then consider using DIVS (SEO can also suffer the same issue as screen readers).
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

Dalek Dave wrote:
Why is DIV better than TABLE?

 
It isn't inherently. Tables are better at displaying tabular data. Divs are better at creating sections within your page. So it's horses for courses.
 
Dalek Dave wrote:
Just wondering the reason why

 
This is the subject of one of the many internicene wars in IT. The pro-div contention (and the one I agree with) is that, you can readily skin your HTML any way you want using CSS. Take a look at http://www.csszengarden.com/[^] (SFW), and look at the several desgins. This is the same HTML with different css applied. It also helps separate out the styling from the markup.
 
That said, for many applications tables are just simpler to implement.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 6

Here[^] is a little helper also.
  Permalink  
Comments
Dalek Dave at 7-Jun-10 11:14am
   
Thanks! :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Thanks, it seems I am not alone in wondering!
 
I suspect further reading is advisable, something to do this evening.
 
I must admit I prefer tables as I can picture in my mind how something will appear before I start doing it.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 5

For Tabular data, Table is best. but we can handle DIV dynamically in JavaScript easily like show/hide/position/etc. I'm always using Table inside a DIV.
<DIV ID="divData">
 <Table>
  <Tr>
   <Td>blah blah</Td>
   <Td>blah blah</Td>
  </Tr>
 </Table>
</DIV>
<a href="javascript:hidediv()">hide div</a>
<a href="javascript:showdiv()">show div</a> 
function showdiv() {
document.getElementById('divData').style.visibility = 'visible';
}
function hidediv() {
document.getElementById('divData').style.visibility = 'hidden';
} 
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 7

when you use table , pages are display until all data are loaded,but in case of div it shown as it get loaded inspite of all page data.so conclusion is response time for div is faster as compare to table.
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 7,903
1 Sergey Alexandrovich Kryukov 7,192
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,820


Advertise | Privacy | Mobile
Web01 | 2.8.1411023.1 | Last Updated 7 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100