<Glazblog/>

Morning laugh

I had missed that entry on Matthew Thomas's weblog:

So how should you mark up text in another language? Here's what I used in my original example:

<i lang="fr">je ne sais quoi</i>

Instead, Matt May suggests

<span lang="fr">je ne sais quoi</span>

and, in his style sheet, italicizes any span with a lang attribute using a simple attribute selector.

These two options have exactly the same semantics. The only difference is that Mr May's version doesn't work in Internet Explorer for Windows. Or in Internet Explorer for Mac. Or in Opera in User Mode. Or in Mozilla with Basic Page Style selected. Or in Firefox with Basic Theme selected. Or in Lynx.

That's a bit of a difference, I must say :-) Very well said, Matthew, very well said.

Comments

1. On Thursday 22 July 2004, 14:54 by jmdesp

Les tags avec pour attributs ne peuvent pas être sélectionné en CSS par une technique qui marche sur un nombre raisonnable de browser ? Si c'est vrai, c'est vraiment une très mauvaise nouvelle.
A partir du moment où l'on gère du contenu multi-langue, il y a des tas de motifs pour décider de faire des mises en valeur qui dépendent de la langue, et le point précédent fait qu'on va être obligé de dupliquer l'information de langue sur autre chose pour pouvoir le sélectionner en CSS.
Ou alors de coder en dur l'info de présentation comme dans l'exemple précédent.

En fait cet exemple est tout à fait valide, il est très souhaitable si on a "<i lang="fr">je ne sais quoi</i>" où l'italique est là *parceque* c'est un élément en français de sortir la notation i du contenu pour pouvoir la mettre dans une règle CSS. Et si cela plante, alors faire peut-être lang="fr" class="lang_fr", c'est merdique (mais au même niveau que le i, et peut-être un peu moins) mais c'est à cause d'un bug. Ce qui est une question séparée et indépendante du fait de savoir s'il faut absolement éliminer i de HTML/XHTML de manière générale.

2. On Thursday 22 July 2004, 20:32 by Prognathous

Very insightful article. I must wonder why mpt is no longer involved in b.m.o., lots of his bug comments were of the same material.

Prog.

3. On Thursday 22 July 2004, 20:46 by TDD

What I would *really* love would be something along the lines of:

span[lang!=/html/@lang] {
font-style: italic;
}

(plus multiple-level italic/normal switching, but that can be done).

This is because I'd love to have a single stylesheet for several languages, and just define the main language in the <html lang="..."> attribute (or xml:lang, if using XHTML 1.1+) and get anything with a lang attribute that is *not* it appear italicized.

Of course, the suggestion above doesn't work now because:

1) There is no != attribute selector operator. There is only =, ~= and |=. I cannot think of a good way to encode != with those...

2) This uses XPath-style syntax that CSS does not allow. You can't traverse easily the DOM this way in CSS.

You could submit that if the document defines a lang for sure, any element with a specific lang attribute *has* to be a different language. That's true enough. So just :

span[lang] {
font-style: italic;
}

should suffice. But it's less expressive.

4. On Thursday 22 July 2004, 21:55 by Greg K Nicholson

"The only difference is that Mr May’s version doesn’t work in Internet Explorer for Windows. Or in..."

It does "work" - it just isn't italic... or at all distinct from the surrounding text.

If you want it to be be emphasised, even in lo-style conditions, use <em lang="fr">je ne sais quoi</em>, avoiding those nasty <i/>s.

re: Matthew Thomas's entry: <sup/> and <sub/> are indeed semantic elements - 28 != 2<sup>8</sup>.

Having said that, in maths-speak "<b>a</b>" is a vector whereas "a" is a linear variable. In those cases, I'd probably use <b class= "vector" >a</b>.

5. On Monday 26 July 2004, 19:36 by fantasai

:not([attr="value"]) ?

6. On Thursday 29 July 2004, 17:04 by mpt

jmdesp: Il n'est pas un bug, il est juste soutien CSS incomplet. De toute façon, il faut mettre l'attribute lang dans *un* element. Pourquois pas <i>? Alors vous n'etes pas besoin class="lang_fr". (Excusez mon français épouvantable, s'il te plaît. J'apprends.)

Prognathous: All Firefox needs at the moment is competent design <listserver.dreamhost.com/... and Firefox has it. So the amount of difference I would make (especially given that the chief Firefox developers rightfully have a jaded view of me) really wouldn't make it worth my time.

Greg: 1: Your suggested markup would be wrong, unless you really wanted the phrase to be emphasized (e.g. spoken slower and louder) *as well as* being in a different language. Occasionally that may be appropriate, but usually it will not. The more people do things like that, the more likely it is UAs will have to start assuming <em> is just <i> in drag (lest they sound silly), in which case we'll be no better off semantically than when everyone was using <i>. 2: Calling <i> "nasty" with no explanation really isn't very convincing. 3: An exponent is just one of the possible meanings for superscript, just like a vector space is just one of the possible meanings for bold. That doesn't make <sup> semantic any more than it makes <b> semantic.

7. On Thursday 29 July 2004, 17:31 by mpt

(Daniel, sir, your automagical URL-handling is broken. And so is your preview of multi-paragraph comments.)