A reason to use tables instead of divs

Reply

Join Date: May 2008
Posts: 174
Reputation: Jen0608 can only hope to improve 
Solved Threads: 10
Jen0608 Jen0608 is offline Offline
Posting Whiz

Re: A reason to use tables instead of divs

 
0
  #21
Mar 23rd, 2009
tables are so oldskool and hard to encode sometimes. but with divs., its a lot easier to code, and easy as well to fix if theres a problem with it. great post.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 63
Reputation: cfajohnson is an unknown quantity at this point 
Solved Threads: 13
cfajohnson cfajohnson is offline Offline
Junior Poster in Training

Re: A reason to use tables instead of divs

 
0
  #22
Mar 23rd, 2009
Originally Posted by MidiMagic View Post
How is this achieved? When you shrink the browser window, or use a different screen resolution, the divs won't stay put.

They will if you do it correctly.
How is this achieved? Whenever I try it, the list won't stay together, or the table pokes outside the div.

Do you have an example? Please post a URL.
They certainly do not respond to the width and height styles correctly.

They certainly do!
I had divs inside of table cells to further format the contents. They never would expand beyond the size of the text they contained.

Your problem is very likely the use of tables.

Again, can you provide an example of the problem?
I had to use absolute measures {height: .75in; width: 1.5in;} to get the div to expand to the size of the containing table cell. 100% height and width did not work.

If you use absolute measures, the div cannot expand. Why would you expect it to?
The table cells were of fixed height because one cell in each row contained an image.

It sounds as if you are using a table for non-tabular purposes; that's a recipe for disaster.
It won't work. Every time I try to make what seems to be a straightforward structure from div tags, something goes blooey in the browser. and it falls apart: Either stuff leaks out of the div, or the object contained in the div is put elsewhere.

Example? My experience does not agree with yours. What are you doing wrong?
I made a simple div just to put a colored box with a border around some text and a table. The table refused to stay inside the div. Either the div got very small and stayed above the table containing the text, or the table stuck out of the div on one side or the bottom. This was WITHOUT any size styles, other than that the table was to be 50 percent wide and aligned right. The div behaved as if only the text was inside it. The code validated with W3C.

Validating is a prerequisite for a working page, but it doesn't guarantee it.
Last edited by cfajohnson; Mar 23rd, 2009 at 6:06 pm.
Chris F.A. Johnson
http://cfajohnson.com
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 16,146
Reputation: jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all jbennet is a name known to all 
Solved Threads: 531
Moderator
Featured Poster
jbennet's Avatar
jbennet jbennet is offline Offline
Moderator

Re: A reason to use tables instead of divs

 
-7
  #23
Mar 23rd, 2009
Dont use tables for layout

It confuses the hell out of screenreaders, and employers risk getting sued for not making thier sites accessible.
If i am helpful, please give me reputation points.
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: A reason to use tables instead of divs

 
0
  #24
Mar 23rd, 2009
That's a myth. Screenreaders aren't confused by tables, they just read them in a specific way. Weird markup order and other 'unusual' div constructs can confuse screenreaders just as much, sometimes more.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: A reason to use tables instead of divs

 
0
  #25
Mar 24th, 2009
Originally Posted by MidiMagic View Post

How is this achieved? When you shrink the browser window, or use a different screen resolution, the divs won't stay put.
They will if you do it correctly.
You keep saying that, but you don't tell the correct way. Are you saving it so you can copyright and sell it?

How is this achieved? Whenever I try it, the list won't stay together, or the table pokes outside the div.
Do you have an example? Please post a URL.
I didn't put up the bad page on the web. I fixed it with a table.

Here is the bad page:
HTML and CSS Syntax (Toggle Plain Text)
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <title>Stuff</title>
  6. <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
  7.  
  8. <style type="text/css">
  9.  
  10. .cenx {text-align: center;}
  11. .ceni {clear: both;}
  12. .bxfix {margin: 0; border: none; padding: 0;}
  13.  
  14. .boxi {margin: 3em; border: solid 2px #0000cc;
  15. padding: 1em; background-color: #ffaaaa;}
  16.  
  17. .boxd {margin: 0; border: none; padding: 0;
  18. width: 50%; background-color: #aaffaa; float: left;}
  19.  
  20. .boxe {margin: 0; border: none; padding: 0;
  21. width: 50%; background-color: #aaaaff; float: right;}
  22.  
  23. .celfil {margin: 0; border: 1px black solid;
  24. padding: .25 em; background-color: #eeeeaa;
  25. width: 100%; height: 100%;}
  26.  
  27. .wfl {width: 100%;}
  28.  
  29. img {margin: 0; border: none; padding: 0;}
  30. body {background-color: #bbffbb; padding: 2%; font-family: sans-serif;}
  31.  
  32. </style>
  33. </head>
  34. <body>
  35.  
  36. <div class="boxi">
  37. <div class="boxd">
  38. <p>The text I want to keep on the left. The text I want to keep on the left.
  39. The text I want to keep on the left. The text I want to keep on the left.
  40. The text I want to keep on the left. The text I want to keep on the left.
  41. The text I want to keep on the left. The text I want to keep on the left.
  42. The text I want to keep on the left. The text I want to keep on the left.
  43. The text I want to keep on the left. The text I want to keep on the left.</p>
  44. </div>
  45. <div class="boxe">
  46. <table>
  47. <tr>
  48. <th><div class="celfil">Code number</div></th>
  49. <th><div class="celfil">Replacement<br />Text</div></th>
  50. </tr>
  51. <tr>
  52. <td>10</td><td>Text string number 1</td>
  53. </tr>
  54. <tr>
  55. <td>20</td><td>Text string number 2</td>
  56. </tr>
  57. <tr>
  58. <td>30</td><td>Text string number 3</td>
  59. </tr>
  60. <tr>
  61. <td>40</td><td>Text string number 4</td>
  62. </tr>
  63. <tr>
  64. <td>50</td><td>Text string number 5</td>
  65. </tr>
  66. <tr>
  67. <td>60</td><td>Text string number 6</td>
  68. </tr>
  69. </table>
  70. </div>
  71. </div>
  72.  
  73. </body>
  74. </html>

I took out the float: left; in the boxd style, and it got worse.

When I took the floats out of both boxd and boxe, it put the table under the text.

They certainly do not respond to the width and height styles correctly.
They certainly do!
See above. They do not.

I had divs inside of table cells to further format the contents. They never would expand beyond the size of the text they contained.
Your problem is very likely the use of tables.

Again, can you provide an example of the problem?
The table is a table of numbers and data.

See the example above. The yellow boxes are supposed to fill the table cells. They do not.

I had to use absolute measures {height: .75in; width: 1.5in;} to get the div to expand to the size of the containing table cell. 100% height and width did not work.
If you use absolute measures, the div cannot expand. Why would you expect it to?
I had to use the absolute measure to get it to expand to fill the container. It refused to expand to fit the container otherwise.

See the yellow boxes generated by the code above. They refuse to expand to fit the container.

It sounds as if you are using a table for non-tabular purposes; that's a recipe for disaster.
See for yourself (I replaced the proprietary data with simple text, but it is a numeric table).

It won't work. Every time I try to make what seems to be a straightforward structure from div tags, something goes blooey in the browser. and it falls apart: Either stuff leaks out of the div, or the object contained in the div is put elsewhere.
Example? My experience does not agree with yours. What are you doing wrong?
Run the code above to see it.

I made a simple div just to put a colored box with a border around some text and a table. The table refused to stay inside the div. Either the div got very small and stayed above the table containing the text, the table stuck out of the div on one side or the bottom, or the table dropped under the text. This was WITHOUT any size styles, other than that the table was to be 50 percent wide and aligned right. The div behaved as if only the text was inside it. The code validated with W3C.
Last edited by MidiMagic; Mar 24th, 2009 at 9:03 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: A reason to use tables instead of divs

 
0
  #26
Mar 24th, 2009
Originally Posted by MattEvans View Post
That's a myth. Screenreaders aren't confused by tables, they just read them in a specific way. Weird markup order and other 'unusual' div constructs can confuse screenreaders just as much, sometimes more.
It's the users of the screenreaders who get confused. they are blind.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Jul 2006
Posts: 1,091
Reputation: MattEvans is a jewel in the rough MattEvans is a jewel in the rough MattEvans is a jewel in the rough 
Solved Threads: 63
Moderator
Featured Poster
MattEvans's Avatar
MattEvans MattEvans is offline Offline
Veteran Poster

Re: A reason to use tables instead of divs

 
0
  #27
Mar 24th, 2009
Indeed.

But absolute positioning (I mean moving the displayed order of things while keeping the actual markup in a different order) is worse for a screenreader user than a (simple) table.. e.g.
HTML and CSS Syntax (Toggle Plain Text)
  1. <table>
  2. <tr>
  3. <td>this is all going to be read</td>
  4. <td colspan="3">in the correct order</td>
  5. </tr>
  6. <tr>
  7. <td>although, perhaps the rows, and</td>
  8. <td>the columns might be announced</td>
  9. <td>by some screenreaders</td>
  10. <td>using certain settings</td>
  11. </tr>
  12. </table>
But...
HTML and CSS Syntax (Toggle Plain Text)
  1. <div>&nbsp;</div>
  2. <div>in backwards order</div>
  3. <div style="position:absolute;left:0;top:0;">this will probably be announced</div>
although, it would appear to be in the correct order to a sighted user.
Plato forgot the nullahedron..
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 63
Reputation: cfajohnson is an unknown quantity at this point 
Solved Threads: 13
cfajohnson cfajohnson is offline Offline
Junior Poster in Training

Re: A reason to use tables instead of divs

 
0
  #28
Mar 25th, 2009
Chris F.A. Johnson
http://cfajohnson.com
Reply With Quote Quick reply to this message  
Join Date: Jan 2007
Posts: 3,203
Reputation: MidiMagic has a spectacular aura about MidiMagic has a spectacular aura about 
Solved Threads: 165
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Nearly a Senior Poster

Re: A reason to use tables instead of divs

 
0
  #29
Mar 28th, 2009
Originally Posted by cfajohnson View Post

Is this what you want: http://cfaj.freeshell.org/testing/MidiMagic.html?
Yes - sort of. That's what I want it to look like. But it renders the real contents of the table cells differently in different browsers that way. I need another box inside the table cell to get rid of the incompatibility.

It's sort of what I ended up doing (I used classes, because there are other tables on the page), but it does not solve the problem of the div not expanding to fill its container. It just removes the div from inside the table cells, rather than making it expand.

Now make it work WITH the divs in the table cells, and the attributes attached to the divs, not the cells. This exactly shows my point: the div does not obey the styles.

The divs were there to solve a browser intercompatibility problem involving the real contents of the divs. Putting the attributes on the table cells causes the incompatibility to appear. But the divs failed too.

My current page has three nested tables to make it work the same on all browsers.
Last edited by MidiMagic; Mar 28th, 2009 at 11:57 pm.
Daylight-saving time uses more gasoline
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 63
Reputation: cfajohnson is an unknown quantity at this point 
Solved Threads: 13
cfajohnson cfajohnson is offline Offline
Junior Poster in Training

Re: A reason to use tables instead of divs

 
0
  #30
Mar 30th, 2009
Originally Posted by MidiMagic View Post
Yes - sort of. That's what I want it to look like. But it renders the real contents of the table cells differently in different browsers that way.

Can you provide screenshots that demonstrate that?

If there is a problem, it should be fixable with CSS.
I need another box inside the table cell to get rid of the incompatibility.

No, you don't. That's probably what is causing your problems.
Chris F.A. Johnson
http://cfajohnson.com
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC