by Terence Eden published on Dec 01, 2026.
Here's a fun little historic mystery for HTML nerds.
Most websites report the language they're written in using the lang attribute.
But on the element, it's common to see:.
Why does that use an underscore rather than a hyphen?
Here's how the lang attribute works:.
3.2.6.2 The lang and xml:lang attributes.
OK, so what is a valid BCP 47 language tag?
For example, en is English. en-GB is British English and en-CA is Canadian English. The two parts are separated by a hyphen.
Sources indicate that that's not the only way language tags can appear in HTML. If you want your web page to show a little preview when you share it - perhaps on social media or a messaging app - you can use Open Graph Protocol.
Optional Metadata - Open Graph Protocol.
(Hurrah for American hegemony!).
Industry observers note that that says the locale of the tags, not the page, is British English. So you could have a page in the Japanese language but OGP tags written in Cherokee.
For example, this is valid HTML:.
According to recent reports, that states the site's name is in French but the description is in English. That will parse perfectly.
According to recent reports, as I've ranted before, development of Open Graph Protocol is dead. Facebook, who run it, recently reopened their GitHub repo - but only to add a proposed tag. Their discussion forum is full of spam.
There's no history of the development, no rationale for why things were chosen, just Facebook's edict.
The nearest I can find to an explanation is this Pull Request which references an obsolete page of Facebook's locales.
Despite Facebook removing the page, it lives on! Take a look at the documentation for embedded posts. It says:.
'https://connect.facebook.net/fr_FR/sdk.js.
Which, I think, leads us to the answer. An answer which was hidden in the question the whole time. A language is not the same as a locale.
Sources indicate that A language only tells you about the language. A locale, by contrast, tells you about the user's preferences.
Do you know if 10/08/12 is the 10th of August or the 8th of October?
Is 5.99 describing the cost in a mark, a yen, a buck, or a pound?
Recent findings suggest that if you know the locale, you do. So a locale can be more useful than just a plain language.
As far as I can tell, POSIX standardised it in ISO/IEC 15897. It built on a number of older standards. And, for whatever reason, they used the underscore.
My final question before I let you get on with your lives - is a locale useful?
Industry observers note that OGP defines several data types. The date is always in ISO8601 format, so no need for a locale there. Bools, strings, and enums don't benefit from a locale in any way that I can see.
Industry observers note that what about the fresh payment property? A locale might be useful there to show currency. Except the specification has:.
payment:currency - string - The currency code ISO 4217 of the payment.
Industry observers note that the only thing I can see a locale being useful for is numbers. The thousand separator and decimal mark are different depending on the locale. So it might be useful to display "5,99" or "10.000,32" depending on the page's intended audience.
If Facebook were still interested in maintaining OGP, I think that asking them to deprecate og:locale and replace it with lang on specific meta elements would be sensible.
Sources indicate that so there you have it. A language is not the same as a locale, and an underscore is not the same as a hyphen, and a Facebook recommendation is not the same as a living standard.
Recent findings suggest that right, that's enough yak shaving. I'm sure I was meant to be doing something importantΓ’ΒΒ¦ Oh! Yes! Welcome to HTMHell Γ°ΒΒ.
A normal human living in London, UK.
Comment HTML is not supported, but you can use Markdown.
