HTML esoterica – en-GB vs. en_GB
Source Entity
Hacker News

The use of hyphens versus underscores in language tags stems from diverging standards between HTML and Open Graph protocols. While BCP 47 mandates hyphens, older meta-data standards often utilize underscores, creating a persistent technical inconsistency.
The Linguistic Divide in Web Standards
In the realm of web development, minor syntax discrepancies often hide deep-seated historical shifts in standardization. The recent discourse surrounding the use of en-GB versus en_GB highlights a classic tension between modern HTML specifications and legacy metadata protocols. While developers might view this as a trivial stylistic choice, it represents a fundamental divergence in how machines interpret human language data across different layers of the web stack.
The BCP 47 Mandate
At the core of the lang attribute is the BCP 47 specification, which governs how languages are identified on the web. BCP 47 is rigorous, explicitly requiring the use of hyphens as delimiters to ensure interoperability across browsers and assistive technologies. By enforcing a strict character set—limited to A-Z and a-z—BCP 47 creates a standardized, machine-readable format that allows search engines and screen readers to parse global content consistently.
Open Graph and the Underscore Legacy
Conversely, the og:locale property, often found within <meta> tags for social media sharing, frequently defaults to the en_GB format using an underscore. This is not an error, but rather a reflection of older POSIX and locale-based naming conventions common in Unix-like systems and early database schemas. When developers copy-paste these tags for SEO purposes, they often inadvertently mix these two distinct standards, creating a fragmented technical identity for their web pages.
Why Consistency Matters
While modern parsers are increasingly resilient, the inconsistency poses risks for semantic web applications and automated translation services. When a page declares its language as en-GB in the HTML tag but en_GB in its Open Graph metadata, it creates a minor data conflict. While this rarely breaks a page, it forces crawlers to resolve conflicting signals, potentially impacting how content is indexed and categorized by global search engines.
Future Trends in Standardization
As the web moves toward more robust semantic structures, we may see a gradual decline in the use of underscores for language identification. However, because the Open Graph protocol is so deeply embedded in social media infrastructure, backward compatibility remains a priority for platform developers. The industry is unlikely to force a breaking change on legacy meta-tags, meaning developers must remain vigilant in their manual implementation.
Conclusion
Understanding the distinction between en-GB and en_GB is more than an exercise in pedantry; it is an exercise in appreciating the evolution of web standards. By adhering to BCP 47 for structural HTML and remaining aware of the historical baggage carried by Open Graph tags, developers can ensure their sites are as technically sound as they are visually appealing.