search

Home  >  Q&A  >  body text

html5 - html的lang属性设置zh-CN好还是en好呢?有什么作用?

html的lang属性设置zh-CN好还是en好呢?有什么作用?现在用的webstorm编辑器,默认就是设置的en

伊谢尔伦伊谢尔伦2784 days ago941

reply all(3)I'll reply

  • 大家讲道理

    大家讲道理2017-04-17 13:23:11

    The lang attribute of HTML can be used to mark the language of a web page or part of a web page. In other words, the lang attribute can not only be used on html tags

        <html lang="en">

    can also be used on other tags:

    <p>You'd say that in Chinese as <span lang="zh-Hans">中国科学院文献情报中心</span>.</p>
    

    It means the language of the natural language within the tag. Or declare the main natural language language used by the entire web page.
    For the value code manual of lang, please refer to:

    http://www.w3schools.com/tags/ref_language_codes.asp

    What does it do?

    To put it simply, it may not have much effect on the program, but it can tell browsers, search engines, and some programs that process Html to do some corresponding processing or things on the language content of the page.
    For example, you can

    • Set css styles or fonts in different languages ​​according to the lang attribute

    • Tell search engines to do precise identification

    • Let the grammar checker do the language recognition

    • Help translation tools do recognition

    • Help the web page reading program to identify
      etc.

    For more information, please refer to:

    https://www.w3.org/International/questions/qa-lang-why

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 13:23:11

    There are no "huge" benefits that you can think of, but referring to the explanation given in w3school below may help you understand.

    When the search engine or browser gets the language tag, it is possible to perform some auxiliary operations for the specified language

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:23:11

    The default setting is en, then the Chrome browser will ask you if you want to translate into other languages~~~:)

    reply
    0
  • Cancelreply