Home API system lang=”en” – CodePen Blog

lang=”en” – CodePen Blog


For most of ’s life, we intentionally avoided this attribute. It’s normally globally set on the document, like…

<html lang="en">

You can set that yourself in a Project, where you’re authoring the entire HTML document. But in Pens, we provide the HTML shell for you.

We always thought we have no idea what language you’re going to author this HTML in so didn’t want to make that choice for you. You can always set it with a little JavaScript after all:

document.documentElement.setAttribute("lang", "en");

But this probably did more harm than good. By far, most Pens never got any language attribute. Accessibility testing always flagged this as a problem.

So, we’re gonna toss lang="en" on the document from now on. You can still it with JavaScript if you like. After talking with some accessibility folks (hat tip Marcy Sutton), we think this will help more than hurt.

Source link


Please enter your comment!
Please enter your name here