ѧϰxhtml¹ý³ÌÖУ¬·¢Ïֺܶà±êÇ©¶¼¿ÉÓÃlangÊôÐÔ£¬µ«ÊÇlangÊôÐÔµÄÓÃ;ÊÇʲôÄØ£¿
ÔÚ¡¶HTML XHTML CSS BIBLE 5th edition¡·Ò»ÊéÖÐÊÇÕâÑù½²½âµÄ£º
Most tags support the lang attribute, which defines the language in which the content of the
tag should be displayed. For example, specifying en corresponds to English; en-US specifies the
United States version of English (as opposed to UK). This attribute has the same format as the
rest of the attributes: lang="en-US".
ÊéÖÐ˵ÊǶ¨ÒåÁ˱êÇ©ÄÚÈÝʹÓõÄÓïÑÔ¡£µ«ÊÇÔÚ¾ßÌåµÄÓ¦ÓÃÖÐҲû·¢ÏÖÓÐʲôÓÃ;һÑù£¿
------------test.html-----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Test tag lang attribute</title>
</head>
<body>
<p lang="zh-CN">ÄãºÃ</p>
<p lang="en-US">hello</p>
<p lang="ja-JP">¤³¤ó¤Ë¤Á¤Ï</p>
<p lang="ko-KR">?????</p>
</body>
</html>
------------test1.html----------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
<title>Test tag lang attribute</title>
</head>
<body>
<p>ÄãºÃ</p>
<p>hello</p>
<p>¤³¤ó¤Ë¤Á¤Ï</p>
<p lang="ko-KR">?????</p>
</body>
</html>
test.htmlʹÓÃÁËlangÊôÐÔÀ´±êʾ±êÇ©ÄÚÈݵÄÓïÑÔ¡£
test1.htmlûÓÐʹÓÃlangÊôÐÔÀ´±êʾ±êÇ©ÄÚÓõÄÓïÑÔ¡£
×¢£ºÎªÁË·ÀÖ¹UTF-8ÄÜÏÔʾËùÓÐÓïÑÔµÄÄÚÈÝ£¬¹Ê<meta>±êÇ©ÖÐÉèÖÃΪGBK¡£
µ«Êǽá¹û·¢ÏÖ£¬Á½¸öÍøҳЧ¹ûÒ»Ñù£¬¶¼ÄÜÕý³£ÏÔʾ¡£
ÊDz»ÊÇ˵Ã÷£¬Õâ¸ölangÊôÐÔûÓÃÄØ£¿»¹ÊÇÓÐʲôÆäËû¿ÉÒÔʹÓõĵط½£¿
1 ¥
ÎÒÊÇÐÂÊÖ
2012-07-22
Èç¹ûä¯ÀÀÆ÷×ñÑW3C±ê×¼£¬langÊôÐÔ¿ÉÒÔÓÃÀ´¶¨ÒåÑùʽ¡£class¶¨ÒåÁËÖ÷ÒªCSS£¬lang¿ÉÒÔÔÚclassµÄ»ù´¡ÉÏ×ö³öÊʵ±Ð޸ġ£
±ÈÈ磺
<style>
p{/*langÎÞЧ*/
font-family: "ËÎÌå"
font-size: 14px;
color: #F00;
}
p:lang(zh-CN){/*lang="zh-CN"*/
font-family: "ËÎÌå"
}
p:lang(en-US){/*lang="en-US"*/
font-family: Arial
}
</style>
ÕâÀïp±êÇ©µÄÖ÷ÒªCSSÖ»¶¨ÒåÁË×ÖÌå´óСºÍÑÕÉ«£¬È»ºó¾ÍÐèҪͨ¹ý±êÇ©µÄlangÊôÐÔÀ´È·¶¨×ÖÌå¡£
langÊôÐԵĺô¦ÄØ£¬¾ÍÔÚÓÚËüµÄCSS¼Ì³ÐÐÔ£¬»òÐíp±êÇ©ÐèÒª¶¨ÒåºÜ¶àÑùʽ£¬µ«²»Í¬µÄÓïÑÔ£¨ÆäʵҲ²»Ö»ÊÇÓïÑÔ£©¿ÉÄÜÐèÒª±ä¶¯ÉÙÁ¿µÄÑùʽ£¬Èç¹û°ÑÕâЩÑùʽ·Ö¿ª¶¨Ò壬¿ÉÄܾͻáËƵÄCSSºÜÈß³¤£¬ÀË·ÑÓû§µÄÁ÷Á¿ºÍÄÚ´æ¡£
±ÈÈ磺
<style>
p{/*langÎÞЧ*/
font-family: "ËÎÌå"
font-size: 14px;
color: #F00;
}
p:lang(zh-CN){/*lang="zh-CN"*/
font-family: "ËÎÌå"
}
p:lang(en-US){/*lang="en-US"*/
font-family: Arial
}
</style>
ÕâÀïp±êÇ©µÄÖ÷ÒªCSSÖ»¶¨ÒåÁË×ÖÌå´óСºÍÑÕÉ«£¬È»ºó¾ÍÐèҪͨ¹ý±êÇ©µÄlangÊôÐÔÀ´È·¶¨×ÖÌå¡£
langÊôÐԵĺô¦ÄØ£¬¾ÍÔÚÓÚËüµÄCSS¼Ì³ÐÐÔ£¬»òÐíp±êÇ©ÐèÒª¶¨ÒåºÜ¶àÑùʽ£¬µ«²»Í¬µÄÓïÑÔ£¨ÆäʵҲ²»Ö»ÊÇÓïÑÔ£©¿ÉÄÜÐèÒª±ä¶¯ÉÙÁ¿µÄÑùʽ£¬Èç¹û°ÑÕâЩÑùʽ·Ö¿ª¶¨Ò壬¿ÉÄܾͻáËƵÄCSSºÜÈß³¤£¬ÀË·ÑÓû§µÄÁ÷Á¿ºÍÄÚ´æ¡£