|
Posted by Alan J. Flavell on 06/01/06 20:04
On Thu, 1 Jun 2006, John Salerno wrote:
> David Dorward wrote:
> > Same as any other element, with the CSS text-align property.
....
> Just a quick followup: Is it good practice to make a separate class
> just to accomplish this alignment,
Well, the td align="right" attribute isn't exactly deprecated yet
(unlike the align attribute on many other elements), but I'd agree
with D.D that it's more hygienic to deal with this via the stylesheet.
> if you don't want all <td>s to be right-aligned?
It may be that you'd want to hang other presentational proposals off
these particular cells - if not now, then maybe later - and defining
an appropriate selector is the way to get set up for that. If you see
what I'm getting at.
> I did class="textlabel" and then a td.textlabel property.
Congratulations on not doing the obvious (but inappropriate)
' class="right" ' which so many would do at this point!
> It doesn't seem very elegant though, for some reason.
Agreed. But it *is* the safest way to get wide acceptability
across browsers and versions.
If you want to be clever, you can style table columns without having
to use classes, by coding selectors like td+td+td, which works fine
for browsers which implement CSS2; but back-level browsers like IE
aren't quite there yet, their newest version is still in beta, and
there will be plenty of folks using older versions for years yet.
It's up to you to decide whether the styling is important enough to
care about those back-level folks - they'll still be able to view the
content, just that it won't look quite the way you want...
http://ppewww.ph.gla.ac.uk/~flavell/tests/tablefun.html (this is just
a test - in the practical situation the styles would be moved out
into a stylesheet, of course).
If you want to take it to extremes, try something like this earlier
experiment: http://ppewww.ph.gla.ac.uk/~flavell/tests/poules2.html ,
although that does make /some/ use of classes (odd/even) to keep the
CSS selectors from getting entirely out of hand.
<digression>
*According to the HTML specification*, the alignment which is
specified by <col align="..."> is /supposed/ to carry through to the
cells of that column. Unfortunately, this rather odd backwater of the
HTML specification is /so/ out of line with the way that CSS works,
that there's something of a clash in browser implementations, and it's
not really something that can be used in practice. In fact it's a
long-standing (possibly in fact *the* oldest) open bug in the Mozilla
bugzilla.
[Back to original message]
|