为什么文档语言会影响具有默认浏览器字体系列的文本,尤其是等宽文本的呈现方式?为什么不将其标准化为仅一种字体?
就我而言,如何在不滥用 lang 属性的情况下解决它?我正在开发一个多语言网站。
<!DOCTYPE html>
<html lang="ja">
<body style="display:flex; flex-direction: column;">
<!-- uses document language of 'ja', non-alnum characters vertically stretched -->
<code><?php function abc($def) { echo "example {$def}"; }</code>
<!-- chinese - consistent size but larger than normal -->
<code lang="zh"><?php function abc($def) { echo "example {$def}"; }</code>
<!-- override lang to 'en', looks normal -->
<code lang="en"><?php function abc($def) { echo "example {$def}"; }</code>
<span>normal text to compare</span>
<span lang="zh">normal text to compare</span>
<span lang="en">normal text to compare</span>
</body>
</html>