Forum Moderators: open

Message Too Old, No Replies

How to declare the language used in html?

         

Makaveli2007

12:46 pm on Oct 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I started out with a template in xhtml and wanted to change it to html 4.01 (which Ive done successfully; it validates). Unfortuantely, I had to remove this line of code from the template:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

No surprise that it didn't validate as it's apparently xhtml, not html. I just tried to find out what line of code, I'll have to use for html, but searching for it only gives me strange results (because I'm using search phrases including the word "language" and html is a "language", too, I guess....) and one document that's about 100 of pages long on how to deliver internationalized html/xhtml, which I hope I don't have to read to get this one right!

What can I use so the browser understands the language is English (or German..or French...etc.) if I'm coding in html 4.01?

Thanks!

EDIT: I just realized that my document validated, despite the fact that I removed the line of code above. Thus I had absolutely no <html> in all of my code, only a </html> at the end of it! Does the validator, not "get" this kind of stuff? I'm surprised, because if there's a </html> in the code, shouldn't it realize that the <html> is missing...or that a <html> has to be at the beginning of the code in the first place for it to validate as html 4.01?

encyclo

12:51 pm on Oct 11, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To define the document language in HTML you use:

<html lang="en">

I just realized that my document validated, despite the fact that I removed the line of code above. Thus I had absolutely no <html> in all of my code, only a </html> at the end of it! Does the validator, not "get" this kind of stuff?

The

html
element is optional in HTML, so the validator is correct in not marking its absence as an error. :)