Do I need the “lang”-tag for Chrome translation?

▼魔方 西西 提交于 2020-01-07 02:00:07

问题


do I need the <html lang="de-DE">-tag for the Chrome translation? Or does Chrome also analyze the words used in the body-part to check in which language the page was written?

Or do I need to add the <html lang="de-DE">-tags at divs at the site?

An what when I use more than one language?


回答1:


The Chrome browser can identify the page language by looking at a number of factors:

1.the character encoding.
2.the HTTP headers.
3.the encoding meta tag.
4.Analysis of the actual characters or words on the page.

So yes you need <html lang="de-DE">-tag.

If you want to use multiple languages for some content u can use elements such as span or div around the content. Here is an example:

<p>If you want to wish hello to someone in hindi.You would say <span lang="hi"> नमस्ते </span>. Namaste</p>


来源:https://stackoverflow.com/questions/35581024/do-i-need-the-lang-tag-for-chrome-translation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!