Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Consequences of not using a lang attribute in an html5 html tag

Tags:

html

If at the start of my html5 doc I simply use:

<!DOCTYPE html><html>

how will my site be at a disadvantage for not using something like:

<!DOCTYPE html><html lang="en">

like image 911
Ryan Avatar asked Jun 18 '11 21:06

Ryan


People also ask

Is HTML lang attribute necessary?

The lang attribute is an essential component in the basic structure of an HTML document. It's important that we define it correctly because it affects many aspects of user experience. Unfortunately, the negative effects a missing or wrong attribute can have aren't always evident.

What is the purpose of the lang attribute in HTML?

The lang global attribute helps define the language of an element: the language that non-editable elements are written in, or the language that the editable elements should be written in by the user.

What happens if lang HTML attribute is not defined for the Web page?

<html> element does not have a [lang] attribute If a page doesn't specify a language for the <html> element, a screen reader assumes the page is in the default language that the user chose when setting up the screen reader, often making it impossible to understand the content.

How do you use lang in HTML?

In a nutshellAlways add a lang attribute to the html tag to set the default language of your page. If this is XHTML 1. x or an HTML5 polyglot document served as XML, you should also use the xml:lang attribute (with the same value). If your page is only served as XML, just use the xml:lang attribute.


1 Answers

Good question, but I think most of what you want to know is simple reference:

http://www.w3.org/TR/html4/struct/dirlang.html

Some highlights:

Language information specified via the lang attribute may be used by a user agent to control rendering in a variety of ways. Some situations where author-supplied language information may be helpful include:

  • 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

I don't believe there are any important differences between HTML4 and HTML5 regarding this.

like image 119
Wesley Murch Avatar answered Sep 30 '22 09:09

Wesley Murch