HTML language setting?

T

T.J.

Hi
Could someone please confirm which is the right way to
display the HTML language setting please.
I have been reading different opinions that it should be;
<html lang="en">
<html lang="eng">
<html lang="en-GB">
Which is the correct version.
TIA.
 
D

Dylan Parry

T.J. said:
<html lang="en">
<html lang="eng">
<html lang="en-GB">
Which is the correct version.

The first and third are both equally valid, but the second is just plain
wrong. The first states that the language is English, whereas the third
goes further to state that the variant is British English. Another one
you may come across is "en-US" for American English.

The second one is wrong because it blatantly ignores the RFC (I forget
which) that states that a two-letter code should be used unless there
isn't one, in which case a three-letter alternative may be used. English
has a two-letter code, so using the three-letter version is wrong.

IMHO, the best to stick with is the first one.
 
S

Steve Pugh

T.J. said:
Could someone please confirm which is the right way to
display the HTML language setting please.
I have been reading different opinions that it should be;
<html lang="en">
<html lang="eng">
<html lang="en-GB">
Which is the correct version.

Both the first and the last are correct.
See http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang which
in turn references http://www.ietf.org/rfc/rfc1766.txt
The three letter codes are not permitted by the HTML 4.01 spec.

Whether there's any point in specifying British English (en-GB) over
just English (en) is open to debate.

Steve
 
J

Jukka K. Korpela

Dylan Parry said:
The first and third are both equally valid, but the second is just plain
wrong.

Indeed, and unfortunately at least one accessibility tool spits out the
wrong version. Cf. to my answer to a fairly similar question in the WebAIM
list recently: http://www.webaim.org/discussion/mail_message.php?id=5923

(Technically, they are all _valid_, just as <html lang="mumbo jumbo!!!">
is. The lang attribute is declared as CDATA in the DTD, so "anything goes".
This is relevant in the sense that validators should _not_ be expected to
check the lang attribute values in any way.)
IMHO, the best to stick with is the first one.

Perhaps pragmatically, though in principle you should give as detailed
information as possible. And if you open an HTML document in a
(sufficiently new version of) MS Word, for checking the spelling, it is
useful to have it perform the checks according to the right variant of the
language (flagging "color" as an error, etc.).
 
T

T.J.

Steve Pugh said:
Both the first and the last are correct.
See http://www.w3.org/TR/html401/struct/dirlang.html#adef-lang which
in turn references http://www.ietf.org/rfc/rfc1766.txt
The three letter codes are not permitted by the HTML 4.01 spec.

Whether there's any point in specifying British English (en-GB) over
just English (en) is open to debate.

Steve


--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <[email protected]> <http://steve.pugh.net/>

Thanks all,
What am I doing wrong with this?
<html lang="en">
When testing the page at
http://www.netmechanic.com/toolbox/html-code.htm
it tells me line 2 of my code is causing browser
compatibility problems.
My page here,
http://www.sim64.co.uk/fps.html
TIA.
 

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

No members online now.

Forum statistics

Threads
474,430
Messages
2,571,676
Members
48,796
Latest member
Greg L.

Latest Threads

Top