I usually use this: <html lang="en">
.
However, I am working on a website that will use two languages and mix them up sometimes in the same sentence or heading.
How would the above code look in this case? Can I use <html lang="lang1 lang2">
?
As far as I can tell from reading the HTML5 spec the lang
attribute:
value must be a valid BCP 47 language tag, or the empty string
Source: http://www.w3.org/TR/html5/dom.html#the-lang-and-xml:lang-attributes
There's no mention in the spec of an array of language strings and every example I've found uses a single language string.
This makes sense since really a given section can only be in one language unless we're creating a new hybrid language.
Since the lang attribute is valid on all HTML elements you can wrap your language specific code in a new tag in order to indicate its language.
<html lang="en">
[...]
<body>
<h1>I am a heading <span lang="de-DE">Eine Überschrift</span></h1>
</body>
</html>