tags:

views:

48

answers:

2

I have markup like this:

 <tr>
      <td>test</td>
      <td>test</td>
      <td>test</td>
      <td>test</td>
      <td>test</td>
 </tr>

That obviously creates a horizontal table. Is is possible, using only CSS to make that table display with only 1 item on each row? The desired output is similar to a unordered list with no margin or bullet points.

+1  A: 

I imagine this should do it:

tr, td { display: block; }

It'll probably break the table it's in though and it does seem like an odd thing to be doing.

Update: I can't get this (or any other technique) to work in IE8 (normal or compatibility mode). It just refuses to change the display of table cells. Very weird. Sorry, I have no workaround for this.

cletus
Thanks, I have no idea why I didn't think of that.
Ramblingwood
I think @cletus should get at least 15% for helping :)
Doug Neiner
turns out this doesn't work in IE... any fixes?
Ramblingwood
I'm pretty sure there are no fixes -ie's rendering of tables when anything other than default positioning is applied is very buggy. Less so in ie8, but still not right.
wheresrhys
Okay. I found my own solution. I have posted it. It works IE7+.
Ramblingwood
+1  A: 

What I ended up doing is this:

HTML as above.

CSS:

td { width:100%; float:left; }

It is surprisingly simple, yet it works really well.

The root cause of this problem is that IE says that tr and td are already block so using block has no effect. IE has no knowledge of the table-row, table-cell and table display modes.

Ramblingwood