Forum Moderators: open

Message Too Old, No Replies

Tables best practices

         

chrisjoha

7:40 am on Aug 5, 2005 (gmt 0)

10+ Year Member



I haven't worked much with tables in a while, but this last week I have been freshing up some projects for a client and there's been a lot of tables. I've seen this thing so many times that I no longer know what's right...

So, basically my question is; in XHTML, which is the correct out of these two?

<td>Some text</td>
<td><p>Some text</p></td>

The table is used for tabular data, but product names and such are text inside it. I've never used the <td><p></p></td> way before, but I'm starting to wonder if it is more semantically correct?

fwordboy

8:08 am on Aug 5, 2005 (gmt 0)

10+ Year Member



I think it depends on how much data is in the table. sometimes lists may belong inside a table cell and sometimes multiple paragraphs.

However, if only a single piece of text or a few words exist inside the cell, then there should be no extra HTML.
eg


<td><p>lots of texts goes here</p>
<p>even more text here</p></td>

or


<td>text</td>

cellularnews

8:23 am on Aug 5, 2005 (gmt 0)

10+ Year Member



I always wrap text in a paragraph - mainly as I give visitors the ability to control the font used to render tha page (good for poor eyesight) and they are set within the p tag.

That is just a personal development point though.

chrisjoha

8:57 am on Aug 5, 2005 (gmt 0)

10+ Year Member



Thanks for the input. I have used lists and paragraphs inside tables too, when there's enough content to do so. I guess my question actually was "should I always wrap table cell text in a <p>?" In which one of you answered yes and one no :) More views on this?

Tidal2

10:06 am on Aug 5, 2005 (gmt 0)

10+ Year Member



cellarnews: Your point about resizing the text surprised me. So I just tried it using IE 6 & Firefox - using view--> text size in the browser.

It resized the text both with a paragraph tag and without one, not sure about older browser though.

tedster

10:09 am on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How about a nearly idiot opinion - use <p> when you have a paragrapgh. Don't use any extra container element if you just have "some text" - which is pretty common with tabular data.

cellularnews

10:48 am on Aug 5, 2005 (gmt 0)

10+ Year Member



cellarnews: Your point about resizing the text surprised me. So I just tried it using IE 6 & Firefox - using view--> text size in the browser.

Many general users do not know about that option in their web browser, so we have a dynamic CSS facility on our site that enables the user to click on a series of larger/smaller letters to permenently set our sites to a font size they prefer.

Also - a lot of sites lock their CSS so that the browser resize doesn't work - leading people to abandon using it.

I read one web major news site where the font is tiny and locked - the only way to read the page is to disable the browser setting completly, which also then makes the page look awful as none of the formatting loads.

MatthewHSE

8:13 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Firefox will resize text no matter how it's formatted or styled, or what the size units are. Try going back to that news site in Firefox, then hold down the CTRL key and roll your mouse wheel. You can make the text about as big or small as you could want.

BlackRaven

10:01 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



wow neat..thanks MatthewHSE