"Garmt de Vries" <gd*****@hotmail.com> wrote:
I have a table listing various translations of the titles of a set of
books. Each row represents a book, each column represents a language.
- - I would very much like to indicate the language for these titles with a
lang=".." attribute.
- - The most obvious thing to do would be using <col> elements, and giving
them the appropriate lang attributes:
Right.
<col lang="fr"></col><col lang="en"></col><col lang="de"></col>
Well, that's invalid in HTML 4.01 and not recommended in XHTML either.
Don't use end tags </col>. If you must play the XHTML game, use
<col lang="fr" /><col lang="en" /><col lang="de" />
That should mark all cells in the first column as French, all cells in
the second column as English, and all cells in the third column as
German, right?
Indeed, except those cells that have their language set in the cells
themselves or in the <tr> elements.
Except that it doesn't seem to work as expected.
Language markup generally doesn't work as expected; the W3C material is far
too optimistic and promises too much in this issue. Stay tuned to having
any lang attribute settings ignored most of the time. Support to them in
speech browsers is getting better, though, as far as I know.
At least, if I include
a CSS declaration like *[lang=fr]{color:green;}, just to see if it
works, it doesn't do anything.
On which browser(s)? For example, IE knows nothing about such selectors.
Opera has some support.
Perhaps I'm misinterpreting the
semantics of <col> or the [attr=value] selector.
I don't think so. Rather, browser support is poor, and there are some
pitfalls in inheritance (in the CSS sense) and in inheritance (in the
obscurely defined HTML sense) for tables.
First, note that *[lang=fr] (which means the same as [lang=fr]) refers to
those elements that have the lang attribute set to value "fr" and this is
probably to be interpreted so that the elements have that attribute in the
markup, not "inherited". Thus, you manage to set (on the few supporting
browsers) the color property for col elements, but this has no effect,
since that property is not inherited (in the CSS sense) into cells. The
language information is "inherited" into cells, but it's still the <col>
element that carries the lang attribute, not <td> elements.
In principle, you could use
:lang(fr) {color:green;}
and this should affect the color of the cells, unless I've missed
something. The selector should match all elements that have their language
set to "fr" either directly in the element's lang attribute or indirectly
by an enclosing element's language setting. This doesn't seem to work even
on Opera, though.
If you try setting the background color, things are different, since the
background behaves differently in CSS. You can set background for a column
and it shines through for all cells that have their own background set to
transparent, which is the default.
I would just set the lang attribute for <col> elements. That's the right
thing to do, and it doesn't take much time. But don't expect to be able to
base styling on it.
To style a column of a table, the really safe way (to the extent that
styling can be safe) is to set a class attribute for each cell in the
column, and use a class selector. This is tedious and makes the source
ugly, but hopefully you can find some automated tool for it.
It's sad that such a basic styling task is so difficult, but the HTML and
CSS table models are really something rather weird. If you wish to get mad
in trying to understand the mess, you might as well start at
http://archivist.incutio.com/viewlist/css-discuss/34844
which probably hits on the nail by discussing how the rendering of tables
is supposed to work in CSS (for some value of "work").
--
Yucca,
http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring:
http://www.cs.tut.fi/~jkorpela/www.html