- From: Tantek Çelik <tantek@cs.stanford.edu>
- Date: Sat, 16 Mar 2002 21:22:54 -0600
- To: Thomas Hurst <tom.hurst@clara.net>, www-style@w3.org
On 3/15/02 6:19 AM, "Thomas Hurst" <tom.hurst@clara.net> wrote: > * Tyler Rasmussen (rasmo2000@hotmail.com) wrote: > >> I am currently working on a webpage using HTML and CSS for a forgiegn >> language class at my school. I find it very annoying to have to type: >> >> <DIV class="es" lang="es"></DIV> > >> <DIV class="en" lang="en"></DIV> >> >> Over and over again. > > Drop the class="" and use CSS 2 selectors and what's already been > described in the HTML: > > div[lang="en"] { > color: black; > background-color: white; > } > > div[lang="es"] { > color: white; > backgorund-color: black; > } > > Unfortunately you'll need to go bug Microsoft to add CSS 2 selector > support to IE, since this will currently only work in Mozilla and Opera, > *grumble* You'll first need to correct the common misconception of using attribute selectors to select on language because it is incorrect, and doesn't work. E.g. if the body has lang="en" then its children are also "en" by default. ... <body lang="en"> <div> </div> </body> ... The div is of language "en" even though the div itself does not have a lang attribute. The selector you listed above: div[lang="en"] will not select the div precisely because the div does not have a lang attribute. Similarly, On 3/16/02 5:38 PM, "Thomas Hurst" <tom.hurst@clara.net> wrote: > *[xml:lang="fr"] { .. } > > *[xml:lang="en"] { .. } > These are also incorrect for the same reason. The _correct_ way to select elements based on language is with the CSS2 :lang() selector, e.g. div:lang(en) { color: black; background-color: white; } div:lang(es) { color: white; backgorund-color: black; } Now, as far as implementations, IE5/Mac implements :lang() whereas I don't know if any of the other browsers do. You'll need to try them out and bug their vendors accordingly. >> I think it would work wonders for pages like this if you could define >> the language of text inside a certain tag by the CSS document. I >> mean, really, language is part of the style of the document. > > No, language is part of the content of a document, since it refers > directly to individual sections of text. > > Saying class="en" and defining language in the CSS actually reduces the > value of the document, since you can no longer directly determine the > language it's written in without going to the otherwise semantically > useless stylesheet; especially bad if you're a search engine. Completely agreed. Tantek
Received on Saturday, 16 March 2002 22:20:19 UTC