"lang"属性更改了我在Google Chrome中的字体设置

EFa*_*nZh 4 html fonts google-chrome

例如:

<!doctype html>
<html lang="zh-cn">
    <head>
        <style type="text/css">
            body
            {
                font-family: sans-serif;
            }
        </style>
    </head>
    <body>
        <div>Test.</div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

此HTML文档显示的字体不是我的浏览器sans-serif字体.对我来说,它是SimSun.

<!doctype html>
<html>
    <head>
        <style type="text/css">
            body
            {
                font-family: sans-serif;
            }
        </style>
    </head>
    <body>
        <div>Test.</div>
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

这是正常的.

它只影响谷歌Chrome中的字体,我认为它可能与CSS属性"-webkit-locale"有关.

这是正常的吗?如何设置"sans-serif"的字体,以便"lang"属性不会更改字体?

Lar*_*tle 5

"在Microsoft Windows XP及更早版本的中文版本中,默认界面字体是seriffed(MingLiU和SimSun),这与产品的大多数其他(包括东亚)区域中使用sans-serif样式不一致.从Windows Vista开始,所有地区的默认界面字体都改为sans-serif样式,使用繁体中文环境中的Microsoft JhengHei和简体中文环境中的Microsoft YaHei.

来自Wikipedia.org http://en.wikipedia.org/wiki/East_Asian_sans-serif_typeface

解:

使用不同的字体样式.中文和西文用户会得到不同的字体,即使它们具有相同的名称.

或者,您可以使用:lang(Lang-Code)规则来区分字体样式.这是一个例子:

<!doctype html>
<html>
    <head>
        <meta http-equiv='Content-Type' content='Type=text/html; charset=utf-8'>
        <style type="text/css">
        body {
            font-family: "Times New Roman", serif;
        }
        :lang(zh-ch){
            font-family: SimSum-18030,SimHei, serif;
        }
        </style>
    </head>
    <body>
        <div lang="zh-ch">Chinese font </div>
        <div>Default font.</div> 
    </body>
</html>
Run Code Online (Sandbox Code Playgroud)

演示:http: //jsfiddle.net/wCuND/

更多信息在这里.

http://www.w3.org/International/questions/qa-css-lang.en.php