Friday, May 17, 2024
HomeCSSDon’t Neglect the “lang” Attribute

Don’t Neglect the “lang” Attribute


An fascinating notification from @cyishere popped up in my Twitter feed the opposite day:

I replied that I assumed this was seemingly as a result of web page’s lang attribute, which on this web site is en-GB — British English. The default for a lot of frameworks is en, (basic English) or en-US (American English). Whereas there won’t be big variations between these and British English, it may have an effect on how sure phrases are pronounced to assistive applied sciences resembling screenreaders. After all, it could have a a lot larger influence on net pages which might be in a distinct language altogether, so it’s best to at all times be sure you change it to the suitable worth!

Replace

Kitty Giraudel talked about that it is perhaps greatest to make use of en slightly than localised English (resembling en-GB or en-US), because it permits folks utilizing screenreaders to select the locale that they’re used to. (Hyperlink to tweet.) The one supply I can discover for that is the feedback part of a 2015 by Adrian Roselli (On Use of the Lang Attribute). It feels like a great name, however I’m undecided there’s a consensus. It appears to not have an effect on spellchecking, because the browser’s settings override it. Once I view this demo in Chrome the phrase “shade” (American English spelling) is underlined as being incorrectly spelled, however in Firefox it’s the British English spelling, “color”.

You may learn extra in regards to the lang attribute on MDN.

The expertise shared by @cyishere serves an vital reminder that folks browse the net in all kinds of the way we’d not concentrate on when constructing our websites, and we should always be certain that we construct with that flexibility in thoughts. Whereas it’s simple to see this unknowability as a hindrance, I imagine that it’s one thing to be embraced. In constructing for the net, now we have the chance to ship content material to customers in a manner that fits them, and the net platform gives us with all kinds of options in HTML and CSS that assist us try this. Beginning with semantic HTML and layering on high with progressive enhancement is a stable technique.

Talking of the lang attribute jogged my memory of Manuel Matuzović’s wonderful article analysing his HTML boilerplate. It accommodates tons of helpful details about most of the components and attributes most of us don’t give a lot thought to day-to-day if, like Manuel, we recycle the identical boilerplate from challenge to challenge. It’s effectively price a learn.



RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments