Language Tags in HTML - Penn State | Accessibility
文章推薦指數: 80 %
The LANG attribute is designed to signal screen readers to switch to another language. The official W3C recommendation is to declare the primary language for ...
SkiptoContent
LanguageTagsinHTML
Synopsis
UseUnicodeencodingwheneverpossible.
UsetheLANGtagtomarkwordsorpassagesoftextinanotherlanguage.Thisworksformajorlanguagesonly.
Considersupplementinglanguagechangeswithatextualindication(visualorhidden)toindicatewhenaforeignlanguagewordorpassageiscoming.
AboutLanguageTagging
TheLANGtag(i.e.thelang=""attribute)isdesignedtosignalscreenreaderspronunciationenginestoswitchtoanotherlanguage.Forthisreasonandother,taggingWebtextasbeinginaparticularlanguageisrequiredinWCAG2.0.
WCAG2.0Guideline3.1.1—"ThedefaulthumanlanguageofeachWebpagecanbeprogrammaticallydetermined."
Evenmorecriticalistouselanguagetaggingtosignalaswitchinlanguages.
WCAG2.0Guideline3.1.2—"Thehumanlanguageofeachpassageorphraseinthecontentcanbeprogrammaticallydeterminedexceptforpropernames,technicalterms,wordsofindeterminatelanguage,andwordsorphrasesthathavebecomepartofthevernacularoftheimmediatelysurroundingtext."
DeclaringPageLanguage
TheLANGattributeisdesignedtosignalscreenreaderstoswitchtoanotherlanguage.TheofficialW3CrecommendationistodeclaretheprimarylanguageforeachWebpagewitha<...lang>attributeinthetag.CodesareISO-639Languagecodes,someofwhicharelistedfurtherdownonthispage.
NOTE:Youmustalsodeclaretheencodingin
additiontothelanguage.Thelanguageanditsscriptareindependent.
DeclaringaU.S.EnglishPage(PennState)
ScreenreaderssupportingthistagcouldswitchtoaBritishaccent.
DeclaringaFrenchPage
ScreenreaderssupportingthistagcouldswitchtoaFrenchaccent. SwitchingLanguages Ifyouswitchlanguageswithinonepage,youcanembedtheLANGattribute inothertagssuchasaP,TD,SPAN,DIVand othertags.Forexample TestTextwithLangTags ThissentenceisindefaultAmericanEnglish. ThissentencewillbereadwithaBritishaccent. Estafraseesenespañol.(Spanish) Cettephraseestenfrançais.(French) Mae’rfrawddeghonyngNghymraeg.(Welsh–NotSupported) ViewtheCode
ThissentenceisinEnglish.
延伸文章資訊
- 1HTML ISO Language Codes - W3docs
ISO Language Codes¶ ... The HTML lang attribute declares the language of a web page or only a par...
- 2Declaring language in HTML - World Wide Web Consortium ...
In some parts of your code you may have a problem. If you have multilingual text in the title ele...
- 3Language Tags in HTML - Penn State | Accessibility
The LANG attribute is designed to signal screen readers to switch to another language. The offici...
- 4HTML Language Codes - Dofactory
A Language Code is a 2-letter abbreviation that specifies a language. HTML uses ISO language code...
- 5HTML Language Codes - List of Two Letter ... - Tutorial Republic