[whatwg] HTML: A DOM attribute that returns the language of a node
L. David Baron
dbaron at dbaron.org
Wed Sep 18 08:10:01 PDT 2013
On Wednesday 2013-05-01 01:01 -0700, Elliott Sprehn wrote:
> On Wed, Apr 24, 2013 at 9:22 AM, Peter Occil <poccil14 at gmail.com> wrote:
> > I have no objection to the name "baseLang" rather than "language" as the
> > name of the DOM attribute.
> > But if there isn't more interest or you decide not to add this DOM
> > attribute, I encourage you to at least:
> fwiw WebKit (and Blink) implement this through CSS inheritance since you
> need to know the lang for all kinds of things and walking up the DOM
> repeatedly would be expensive.
> -webkit-locale is inherited by default and contains the enclosing @lang
> value. You can query it through getComputedStyle(node).webkitLocale. That
> doesn't help your custom parser though.
In Gecko it's also implemented through CSS inheritance, but it's not
exposed to Web content as a CSS property. (Internally it's
'-x-lang', but that name isn't exposed.)
We use the language for:
* font selection
* language-specific text-transform behavior
* hyphenation (which doesn't work unless it's explicitly specified,
as required by http://dev.w3.org/csswg/css-text/#hyphens-property )
𝄞 L. David Baron http://dbaron.org/ 𝄂
𝄢 Mozilla https://www.mozilla.org/ 𝄂
Before I built a wall I'd ask to know
What I was walling in or walling out,
And to whom I was like to give offense.
- Robert Frost, Mending Wall (1914)
More information about the whatwg