lang Attribute

Contact Us or call 1-877-932-8228
lang Attribute

lang Attribute

The lang attribute is used to tell the browser (or other user agent) the language contained within an element. While it is not required, the W3C recommends that lang be included in the html tag of all HTML documents, like so:

<html lang="en">

According to the W3C, this is helpful in:

  • Assisting search engines.
  • Assisting speech synthesizers.
  • Helping a user agent select glyph variants for high quality typography.
  • Helping a user agent choose a set of quotation marks.
  • Helping a user agent make decisions about hyphenation, ligatures, and spacing.
  • Assisting spell checkers and grammar checkers.

If a portion of the page is written in a different language, you can wrap that portion in a tag that includes the lang attribute, like this:

<span lang="fr">Bonjour, mon ami!</span>