html validation error for html lang attribute

梦想与她 提交于 2019-12-10 10:34:36

问题


I am getting this error message:

This document appears to be Lorem ipsum text but the html start tag has lang="en". Consider using lang="zxx" (or variant) instead.

From line 5, column 32; to line 5, column 47

html lang="en"

For further guidance, consult Tagging text with no language, Declaring the overall language of a page and Choosing language tags.

If the HTML checker has misidentified the language of this document, please file an issue report or send e-mail to report the problem.

for html lang = "en" attribute

What should I do right now ?


回答1:


You're using lorem ipsum, which isn't English. Changing the language attribute to "zxx" should fix the validation warning. Zxx is used when the language is unknown.

Your options: 1) Change "en" to "zxx" --- html lang="zxx" 2) Replace lorem ipsum with English dummy text and keep "en" 3) Ignore the warning until you update your page with real content

https://github.com/validator/validator/issues/321




回答2:


Use lang="zxx" to tagging text with no language.

You can use lang attributes in your block and inline elements like <p>, <span>, <a> etc., as long as your page is in English, for example:

<p lang="zxx">Lorem ipsum</p>

Webpage in English language:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Test</title>
    <meta charset="utf-8">
</head>
<body>
    ...
    <!-- Elements in English: without lang attribute -->
    <p>Hello World</p>
    ...
    <!-- Elements in other languages: with lang attribute -->
    <p lang="de">Hallo Welt</p>
    ...
    <!-- Elements with Unknown language: with lang (zxx) attribute -->
    <p lang="zxx">Lorem ipsum</p>
    ...
    <!-- Mixed -->
    <p>This Page contains <span lang="zxx">Lorem ipsum</span> Text!</p>
    <p>German Words like: <span lang="de">Hallo, Welt</span></p>
    <p lang="zxx">Lorem ipsum <span lang="en">Hello World</span></p>
    <p>The language is in <span title="Spanish" lang="es">Español</span></p>
    ...
</body>
</html>

Or HTML language declaration for unknown language:

<!DOCTYPE html>
<html lang="zxx">
<head>
    <title>Lorem ipsum</title>
    <meta charset="utf-8">
</head>
<body>
    ...
    <!-- don't need lang attribute -->
    <p>Lorem ipsum dolor sit amet</p>
    ...
    <!-- The language is known -->
    <p lang="en" title="English">Hello World</p>
    <p lang="de" title="German">Hallo Welt</p>
    ...
</body>
</html>


来源:https://stackoverflow.com/questions/40210470/html-validation-error-for-html-lang-attribute

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