lang= tag - what's it for?

B

Ben Bullock

On an anchor, I can write

<a lang=jp href="http://http://aor.ktplan.jp/">Site name</a>

but I'm wondering how much I can do with the "lang=jp" tag. I can make the
link colours come out as different, but unless the user knows what meaning
I've attached to the colours that won't help.

In this case, "jp" means "Japanese", so is there a way to use the "lang=jp"
tag to, for example, make an image of a Japanese flag or text explaining
that the link is in Japanese come up?

Or, if not, what is the "lang=jp" tag for?
 
A

Adrienne

On an anchor, I can write

<a lang=jp href="http://http://aor.ktplan.jp/">Site name</a>

but I'm wondering how much I can do with the "lang=jp" tag. I can make
the link colours come out as different, but unless the user knows what
meaning I've attached to the colours that won't help.

In this case, "jp" means "Japanese", so is there a way to use the
"lang=jp" tag to, for example, make an image of a Japanese flag or text
explaining that the link is in Japanese come up?

Or, if not, what is the "lang=jp" tag for?

http://www.w3.org/TR/html4/struct/dirlang.html#adef-lang
 
B

Ben Bullock

Adrienne said:

Thanks for the link Adrienne. I had a look at it, and I can see why "lang="
would be useful in a quoted piece of text, as in the example given. My
question is specifically what the use of "lang=" is in an anchor statement.
Does the "lang=jp" in <a lang=jp href=...> </a> refer to the text between >
and < only? Was I mistaken in thinking it was meant to indicate that the
link goes to a site which is in a foreign language?

Thanks for any more advice.
 
P

Philip Ronan

Ben Bullock said:
[Re. "lang" attribute in A tags]
Was I mistaken in thinking it was meant to indicate that the
link goes to a site which is in a foreign language?

Yes you were. That's what the "hreflang" attribute is for. In an <A>
element, "lang" indicates the language of the anchor text (i.e., the text
between "<A>" and "</A>"). So for example:

<UL>
<LI><A href="index.fr.html" hreflang="fr" lang="fr">Lisez cet article en
français.</A>
<LI><A href="index.de.html" hreflang="de" lang="de">Lesen Sie diesen
Artikel auf Deutsch.</A>
</UL>

This information is particularly useful to speech synthesizers, but you
could use CSS to represent it visually in (some) graphical browsers if you
like. For example:

A[hreflang=fr] { font-family: "Lucida Blackletter", cursive; }
A[hreflang=de] { font-family: "Lucida Calligraphy", cursive; }

Try to avoid flag icons -- they're generally a bad idea.
 
B

Ben Bullock

Philip Ronan said:
Ben Bullock said:
[Re. "lang" attribute in A tags]
Was I mistaken in thinking it was meant to indicate that the
link goes to a site which is in a foreign language?

Yes you were. That's what the "hreflang" attribute is for. In an <A>
element, "lang" indicates the language of the anchor text (i.e., the text
between "<A>" and "</A>"). So for example:

Thanks for sorting that out, and thanks to David Dorward for the link too.
<UL>
<LI><A href="index.fr.html" hreflang="fr" lang="fr">Lisez cet article en
français.</A>
<LI><A href="index.de.html" hreflang="de" lang="de">Lesen Sie diesen
Artikel auf Deutsch.</A>
</UL>

This information is particularly useful to speech synthesizers, but you
could use CSS to represent it visually in (some) graphical browsers if you
like. For example:

A[hreflang=fr] { font-family: "Lucida Blackletter", cursive; }
A[hreflang=de] { font-family: "Lucida Calligraphy", cursive; }

Try to avoid flag icons -- they're generally a bad idea.

Flag icons may be a bad idea, but using different fonts or colours to
indicate that the link is in one language or another is non-intuitive and
will not make things easier to understand. After all, there is no font or
colour associated with "English" or "Japanese".

Anyway, does "hreflang" give me any way to add some fixed text or an icon to
the link? David's link says it is for "user agents", i.e. web browsers.
Assuming it doesn't, I'll try to find some way to sort out indicating the
end language at the preprocessor level.

Thanks again for the help.

Ben.
 
P

Philip Ronan

Ben Bullock said:
Flag icons may be a bad idea, but using different fonts or colours to
indicate that the link is in one language or another is non-intuitive and
will not make things easier to understand.

I'm not going to disagree with that. :)
Anyway, does "hreflang" give me any way to add some fixed text or an icon to
the link?

Yes of course. That's why I gave you an example of CSS in my last post. Take
a look at this: http://www.w3.org/TR/REC-CSS2/selector.html#before-and-after
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top