Multi-language site and HTML lang tag

Dear colleagues,
How do you handle the HTML language tag when building multilingual sites?
Do you ignore the difference between <html lang="xx"> and the content’s language?
Or do you add language specific tags for the different content?
Or do you load different lang tags?
Thanks for your suggestions.
Johannes

I’d set the language code in the tag:

<html lang="<?= $site->language()->code() ?>">

Thank you for your quick reply.
But this delivers an empty lang tag, as the w3org-validator states.

What do you mean with “empty lang tag”?

I’ll copy the validator’s warning:

the html start tag has an empty lang attribute

and the displayed code:

<html lang="">.

It is the second line of the code, so nothing is declared or specified than the doctype. I expected something like this.

So $site->language()->code() does not output anything? That’s weird. But you have multi-lang enabled in your config.php?

No, no output at all.
But: I can add the code later to an element and everything is fine. For example
`````

That won’t output anything either, because it should be:

<main lang="<?php echo $site->language()->code() ?>">

(your code is missing the echo command)
If that outputs something, it will also do so in the html tag.:slight_smile:

That’s it!
Thanks a lot.