943,731 Members | Top Members by Rank

Ad:
You are currently viewing page 3 of this multi-page discussion thread; Jump to the first page
Mar 23rd, 2009
0

Re: A reason to use tables instead of divs

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.
Reputation Points: -30
Solved Threads: 10
Junior Poster
Jen0608 is offline Offline
179 posts
since May 2008
Mar 23rd, 2009
0

Re: A reason to use tables instead of divs

Click to Expand / Collapse  Quote originally posted by MidiMagic ...
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.
Quote ...
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.
Quote ...
They certainly do not respond to the width and height styles correctly.

They certainly do!
Quote ...
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?
Quote ...
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?
Quote ...
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.
Quote ...
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?
Quote ...
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.
Reputation Points: 25
Solved Threads: 23
Junior Poster
cfajohnson is offline Offline
193 posts
since Dec 2008
Mar 23rd, 2009
-1

Re: A reason to use tables instead of divs

Dont use tables for layout

It confuses the hell out of screenreaders, and employers risk getting sued for not making thier sites accessible.
Moderator
Featured Poster
Reputation Points: 1764
Solved Threads: 574
Moderator
jbennet is offline Offline
16,505 posts
since Apr 2005
Mar 23rd, 2009
0

Re: A reason to use tables instead of divs

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.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Mar 24th, 2009
0

Re: A reason to use tables instead of divs

Quote ...
Quote ...
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?

Quote ...
Quote ...
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.

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

Quote ...
Quote ...
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.

Quote ...
Quote ...
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.

Quote ...
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).

Quote ...
Quote ...
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.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Mar 24th, 2009
0

Re: A reason to use tables instead of divs

Click to Expand / Collapse  Quote originally posted by MattEvans ...
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.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Mar 24th, 2009
0

Re: A reason to use tables instead of divs

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.
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Mar 25th, 2009
0

Re: A reason to use tables instead of divs

Reputation Points: 25
Solved Threads: 23
Junior Poster
cfajohnson is offline Offline
193 posts
since Dec 2008
Mar 28th, 2009
0

Re: A reason to use tables instead of divs

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.
Reputation Points: 730
Solved Threads: 181
Nearly a Senior Poster
MidiMagic is offline Offline
3,314 posts
since Jan 2007
Mar 30th, 2009
0

Re: A reason to use tables instead of divs

Click to Expand / Collapse  Quote originally posted by MidiMagic ...
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.
Quote ...
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.
Reputation Points: 25
Solved Threads: 23
Junior Poster
cfajohnson is offline Offline
193 posts
since Dec 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: Attempting 2.0 Design
Next Thread in HTML and CSS Forum Timeline: Style Issue While Becoming Complient





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC