Daily Tips & Tricks for Web Enthusiasts

Your HTML Element Needs a Language Attribute

Make sure you always specify a language in your <html> element, like this:

<html lang="en">

Why is this important? Here are two reasons:

  1. The language attribute helps facilitate automatic translation of your content into other languages.
  2. Screen readers use the language attribute to make sure they’re using the proper language when reading your content.

Both of these give more people easier access to your content, and all you have to do is add a single attribute!

Wondering what the code for your language might be? They’re all in the IANA Language Subtag Registry. Just search that page for the name of the language you want and use the associated subtag value in your HTML element’s lang attribute.