Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

1. Fundamental Syntax and Semantics > 1.3. Specifying the Language

1.3. Specifying the Language

Problem

You want to specify the primary language of your web page.

Solution

Add the lang attribute and appropriate value to your opening html element:

<html lang="en">

Discussion

Browsers, screen readers, and other user agents use the lang attribute to determine the language in which the content should be interpreted. The example above specifies English via the en value.

Declaring a document’s primary language isn’t a requirement for HTML5 (or any of the previous versions, for that matter). It is, however, a good practice for both usability and accessibility.

See Also

Mark Pilgrim’s “Dive Into Accessibility” discussion about identifying your document language at http://diveintoaccessibility.info/day_7_identifying_your_language.html.


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial