µ±Ç°Î»Ö㺠´úÂëÃÔ >> HTML/CSS >> html langÊôÐԵIJ»½â
  Ïêϸ½â¾ö·½°¸

html langÊôÐԵIJ»½â

Èȶȣº841   ·¢²¼Ê±¼ä£º2012-10-24 14:15:58.0
html langÊôÐÔµÄÒÉ»ó
ѧϰ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ºÜÈß³¤£¬ÀË·ÑÓû§µÄÁ÷Á¿ºÍÄÚ´æ¡£
  Ïà¹Ø½â¾ö·½°¸