PDA

View Full Version : table semantics - a twist in my sobriety ...


brothercake
03-15-2003, 02:32 PM
I have a data table which is marked up like this:

<table width="80%" cellpadding="0" cellspacing="1" border="1" summary="This table charts responses ... (snip) ">
<caption><abbr title="Question"><span class="abbr" title="Question"><b>Q</b></span></abbr>:
Do you approve or dissapprove ... (snip)</caption>
<thead>
<tr>
<td>&nbsp;</td>
<th class="abbr" abbr="Percent" title="Percent">%</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="2">Base: 985</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Approve</td>
<td>36</td>
</tr>
<tr>
<td>Disapprove</td>
<td>53</td>
</tr>
<tr>
<td>Don't know</td>
<td>12</td>
</tr>
<tr>
<td>Net approve</td>
<td>-17</td>
</tr>
</tbody>
</table>

The table looks like this (http://af.brothercake.com/_tables.html)

The problem is - the TH element has implicit center alignment, but the TD elements do not, therefore if CSS is turned off (and in legacy browsers) the heading is always misaligned with the figures.

How it looks aesthetically isn't so much the issue - it's just that it's confusing like that - particularly when the table becomes complex, but even with this example, I think it's counter-intuititive - for the sake of usability and comprehension, the alignments should be consistent.

So how do I center the TDs (or left-align the TH) ... without CSS or using the align attribute. I want it right without CSS because I want it to work universally; and without the align attribute, because ... well... the page is XHTML 1.1 - if I use align it falls back to 1.0 Transitional :(

Any ideas? Are there any table semantics I can use which are visually interpreted as center alignment on the TDs.

brothercake
03-20-2003, 11:55 AM
Well I found the answer .. sort of:

<colgroup halign="left" />
<colgroup halign="center" />

this is the correct syntax, but *no web browser I tested* actually implements it. However if I change it to incorrect syntax

<colgroup align="left" />
<colgroup align="center" />

Then it works in IE and Opera.

What's the good of all that? None that I've been able to figure out :rolleyes:

Jerome
03-20-2003, 12:46 PM
I am old and walking always far behind, but what You need is something like the good old <CENTER></CENTER> Tags, not?

Jerome

brothercake
03-20-2003, 02:01 PM
I wanted a valid XHTML solution ... <center> doesn't exist in XHTML; but thanks anyway :)

meow
03-20-2003, 02:08 PM
It doesn't exist in HTML or XHTML strict.
"align" as an attribute to TD and TH isn't deprecated so that would be your option.

brothercake
03-20-2003, 02:16 PM
Originally posted by meow
It doesn't exist in HTML or XHTML strict.
"align" as an attribute to TD and TH isn't deprecated so that would be your option.

I was under the impression that align *is* deprecated as an attribute of TD and TH in XHTML 1.0 Strict and XHTML 1.1 ... but now I come to check, it isn't.

Cool :) But since I need to use the <script /> language attribute, this project will have to be 1.0 Transitional in any case.

Thanks for the responses :thumbsup:

meow
03-20-2003, 02:28 PM
Nothing is deprecated in XHTM. It all happened back in 1997-99. That X isn't all that magic. :o

justame
03-20-2003, 03:53 PM
bro...
"quote...Any ideas?...endquote"
ummm whattt just a boutŪ using just a smallŪ image for your 'header'??? n' thattt way you could have it just a left/center/rightŪ on the image width itself???

just a notherŪ suggestion...:O)))

brothercake
03-20-2003, 04:30 PM
Originally posted by meow
Nothing is deprecated in XHTML.

Lots of things are deprecated - attributes and elements which are valid HTML Transitional are not valid XHTML ... or is that what you mean - that nothing is deprecated between XHTML and HTML *Strict* ?


justame - image spacers?? Image spacers !!?? ;) :D

meow
03-21-2003, 12:25 AM
I mean that the deprecation occurred in HTML4. XHTML just added the slashes. It didn't deprecate any elements or attributes.

In fact, a lot of them have 'always' been deprecated. HTML4 both added and deprecated a bunch at the same time. :o

brothercake
03-21-2003, 12:52 AM
Originally posted by meow
I mean that the deprecation occurred in HTML4. XHTML just added the slashes. It didn't deprecate any elements or attributes.

Oh well that's not completely true - http://www.w3schools.com/tags/tag_img.asp - there for example, the "align" attribute is lost in 1.0 Strict.

XHTML also added a new attribute - <blockquote cite="http://url_of_source_document"> :)

meow
03-21-2003, 01:00 AM
Nope, it was deprecated in HTML4.0. :D

http://www.w3.org/TR/1998/REC-html40-19980424/index/attributes.html

It's just that hardly anyone cared until they jazzed it up with that X. Do you find anything at the XHTML page at w3 about deprecated elements and attributes? XHTML1.0 = HTML4.01 as far as this is concerned. :p

brothercake
03-21-2003, 01:18 AM
Allright then, I stand corrected :)

cg9com
03-21-2003, 10:41 PM
werent things like <font> and <center> deprecated in xhtml?

meow
03-21-2003, 11:45 PM
Yes, they ARE deprecated but they were that already in HTML4.

"XHTML 1.0 [...] is the first document type in the XHTML family. It is a reformulation of the three HTML 4 document types as applications of XML 1.0."