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 Code Reference - W3Schools
ISO Language Codes. You should always include the lang attribute inside the <html> tag, to declar...
- 2List of All Locales and Their Short Codes? - Stack Overflow
List of all languages with names and ISO 639-1 codes in all languages and all data formats. Forma...
- 3HTML Language Codes - Quackit Tutorials
You can declare the language of an HTML document within the <html> tag by using the lang attribut...
- 4HTML Language Codes - List of Two Letter ... - Tutorial Republic
- 5HTML lang attribute / ISO language code reference / Culture ...
HTML lang attribute / ISO language code reference / Culture names - html-languages.txt.