RE: What is the 'lang' attribute and why do I need it?

Wow. That was quick! Great start.

Quick comments on first read below...

> -----Original Message-----
> From: Deborah Cawkwell [mailto:deborah.cawkwell@bbc.co.uk] 
> Sent: 09 February 2004 17:24
> To: Richard Ishida; GEO
> Subject: FAQ: What is the 'lang' attribute and why do I need it?
> 
> 
> Suggestions to improve this FAQ, especially its bittiness, 
> most welcome. The main part of the FAQ was intended to be 'why'.
> 
> Thanks
> 
> Deborah
> 
> -----------------------------------------
> 
> Question
> 
> What are 'lang' attributes and why do I need them?
> 
> 
> Answer
> 
> The 'lang' attribute contains information about the 
> language(s) used in the HTML page.
> 
> According to HTML 4.01 Specification W3C Recommendation 24 
> December 1999 
> (http://www.w3.org/TR/html401/struct/dirlang.html#h-8.1.3), 
> this information is used for:
> 
> - Assisting search engines 
> - Assisting speech synthesizers and Braille translators
> - 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 
> 
> Also:
> - The lang tag is required by the Web Accessibility 
> Initiative and some governmental policies in some countries.
> - The 'xml:lang' attribute is the standard way to identify 
> language information in XML.
> 
> The 'html' element should contain a lang attribute with the 
> predominant language of the page. 
> For example, <html lang="pt">. The value of the lang 
> attribute is usually a two-letter country code. (FAQ:

Country code -> language code

 
> Two-letter or three-letter language codes)
> 
> Where the language changes, that change should be clearly 
> identified. For example, <p lang="en">He viewed Deidre's 
> predicament with a certain amount of <span 
> lang="de">Schadenfreude</span>.</p>



I would use an example that includes a definitely foreign word.  Borrowed
terms are rather controversial - when are they part of the language and when
not?  (WAI is struggling with this at the moment.)  A useful example is "The
French word for 'cat' is 'chat'." because the french bit is ambiguous (could
sound like English).

Maybe have some subheadings.  Eg.
What is it?
Why is it needed?
How do you use it? (which is what now follows)


> 
> HTML and XML have different syntax. When serving XHTML as 
> text/html, you should use both the lang attribute and the 
> xml:lang attribute in the html element.
> (http://www.w3.org/International/tutorials/tutorial-lang.html)
> 
> 	eg: HTML: <html lang="fr-CA">
>        XHTML 1.0 served as text/html: <html lang="zh-CN" 
> xml:lang="zh-CN" xmlns="http://www.w3.org/1999/xhtml">

Be careful with the Chinese example here.  Maybe better use another, since
zh-Hans now would be more appropriate.  (I know I used that in my tutorial,
but I correct it later - maybe I should change it too.)


>        
> For more information on language tagging mark-up, see 
> (http://www.w3.org/International/O-HTML-tags.html).
> 
> CSS2 uses the 'lang' attribute powerfully as a pseudo class. 
> (http://www.w3.org/International/questions/qa-css-lang.html).

Well, 'can use it' - unfortunately it doesn't work in IE yet.  But the
concept of language specific styling is a very powerful one, which could
maybe be brought out by some examples.


> 
> Which tags? The attribute can be applied to any element 
> except applet, base, basefont, br, frame, frameset, iframe, 
> param, or script.

Ie. You can use it for img and object tags etc.! ;)

Perhaps what we've started into here is another subsection that could be
called something like "Examples of uses for the lang tag"

> 
> A common use for meta is to specify keywords that a search 
> engine may use to improve the quality of search results. When 
> several meta elements provide language-dependent information 
> about a document, search engines may filter on the xml:lang 
> attribute to display search results using the language 
> preferences of the user.
> (http://www.w3.org/TR/2002/WD-xhtml2-20020805/mod-meta.html)
> 
> For example, 
> 
> <-- For speakers of US English -->
> <meta name="keywords" lang="en-us" 
>          content="vacation, Greece, sunshine"/>
> <-- For speakers of British English -->
> <meta name="keywords" lang="en" 
>          content="holiday, Greece, sunshine"/>
> <-- For speakers of French -->
> <meta name="keywords" lang="fr" 
>          content="vacances, Gr&egrave;ce, soleil"/>
>          
> The lang attribute should be specified for alt-attributes and
> longdesc-attributes.         
> 
> 
> Useful links
> 
> HTML 4.01 Specification W3C Recommendation 24 December 1999: 
> http://www.w3.org/TR/html401/struct/dirlang.ht> ml#h-8.1.3.
> 
> XHTML 2.0 W3C Working Draft 5 August 2002 
> http://www.w3.org/TR/2002/WD-xhtml2-20020805/mod-meta.html
> Web Accessbility Initiative: lang attribute - 
> http://www.w3.org/TR/WCAG10/#gl-abbreviated-> and-foreign
> 
> Tutorial: Language markup in XHTML and CSS 
> (DRAFT): http://www.w3.org/International/tutorials/tutorial-lang.html
> FAQ: Styling using the lang attribute: 
> http://www.w3.org/International/questions/qa-> css-lang.html
> 
> FAQ: Two-letter or three-letter language 
> codes: http://www.w3.org/International/questions/qa-lang-2or3.html
> 
> 
> 
> BBCi at http://www.bbc.co.uk/
> 
> This e-mail (and any attachments) is confidential and may 
> contain personal views which are not the views of the BBC 
> unless specifically stated. If you have received it in error, 
> please delete it from your system. 
> Do not use, copy or disclose the information in any way nor 
> act in reliance on it and notify the sender immediately. 
> Please note that the BBC monitors e-mails sent or received. 
> Further communication will signify your consent to this.
> 

Received on Monday, 9 February 2004 12:52:01 UTC