HTML Guide
Based on the content of the document, the W3C validator thinks that it’s written in English. Consider explicitly specifying the language using the lang property.
Example:
<html lang="en">
Learn more:
Last reviewed: October 27, 2022
Related W3C validator issues
Instead of using the isolang attribute to define the language of the document, you can use lang with an ISO 639-1 two character code.
For example, for Portuguese:
<html lang="pt">
The value en-EN is not a valid language tag for the hreflang attribute on a link element.
The hreflang attribute specifies the language (and optionally, the region) of the linked resource to help search engines and browsers deliver the correct localized version. Language tags should follow BCP 47 standards, with primary language subtags (like en) and optional region subtags (like US). A correct region subtag for English would be en-US (English as used in the United States) or en-GB (United Kingdom). Double language subtags like en-EN are invalid because the region subtag must be a valid country code, not a repeat of the language code.
Correct usage:
<link rel="alternate" href="https://example.com/en/" hreflang="en">
<link rel="alternate" href="https://example.com/en-gb/" hreflang="en-GB">
<link rel="alternate" href="https://example.com/en-us/" hreflang="en-US">
Incorrect usage:
<link rel="alternate" href="https://example.com/en-en/" hreflang="en-EN">
Use en, en-US, or en-GB as appropriate for English-language content, but never en-EN.
The specified language code in the lang attribute of the <html> tag is not a valid ISO code.
Always use a language attribute on the <html> tag to declare the default language of the text in the page, using the lang property.
Example:
<html lang="fr">
Ensure to escape unescaped angle brackets by using < for < and > for > in HTML.
HTML documents may contain special characters where using the raw characters could lead to errors or misinterpretation by the browser. This is common with angle brackets < and >, which are used for delimiting HTML tags. If these characters are used in textual content or mistakenly typed in an unintended manner, it can cause issues, such as unexpected tag closure or rendering problems.
In your case, the W3C HTML Validator has detected an occurrence of the characters </> which might actually be intended as a simple display of these symbols, but are misinterpreted as an incomplete HTML tag. To prevent such issues, you should escape these characters using HTML character entities like < for the less-than sign and > for the greater-than sign.
Example:
You might want to display code or a message like This is the “<tag>” example in your HTML content. The direct use of < and > can break the HTML content. Instead, use:
<p>This is the "<tag>" example.</p>
If you are trying to display the stand-alone sequence </>, you should use:
<p>Saw “</>”</p>
These replacements ensure the validator processes your HTML correctly without mistaking your intended display content for HTML coding errors.
Based on the content of the document, the W3C Validator has determined that it’s written in Arabic, and it suggests you specify the direction of text from right to left like this:
<html dir="rtl" lang="ar">
Based on the content of the document, the W3C validator thinks that it’s written in English, but the lang property in the <html> element specifies a different language. Check the language of the document, if it matches the lang property you can safely ignore and mute this warning.
Example:
<html lang="fr">
The lang attribute on the <html> element tells browsers, search engines, and assistive technologies what language the page content is written in. The validator uses heuristic analysis of the actual text on the page to detect the likely language, and when there’s a mismatch, it flags the discrepancy.
Why This Matters
An incorrect lang attribute causes real problems for users and systems that rely on it:
- Screen readers use the lang attribute to select the correct pronunciation engine. A French document marked as English will be read aloud with English pronunciation rules, making it incomprehensible.
- Search engines use the language declaration for indexing and serving results to users searching in a specific language.
- Browser features like automatic translation prompts and spell-checking rely on the declared language.
- Hyphenation and typographic rules in CSS also depend on the correct language being declared.
Common Causes
- Copy-pasting a boilerplate — Starting from an English template but writing content in another language without updating lang.
- Multilingual sites — Using the same base template for all language versions without dynamically setting the lang value.
- Incorrect language subtag — Using the wrong BCP 47 language tag (e.g., lang="en" instead of lang="de" for German content).
When You Can Safely Ignore This Warning
This is a warning, not an error. The validator’s language detection is heuristic and not always accurate. You may safely ignore it if:
- Your page contains very little text, making detection unreliable.
- The page has significant amounts of content in multiple languages, but the lang attribute correctly reflects the primary language.
- The detected language is simply wrong (e.g., short text snippets can confuse the detector).
If you’re confident the lang attribute is correct, you can disregard the warning.
How to Fix It
Identify the primary language of your document’s content and set the lang attribute to the appropriate BCP 47 language tag. Common tags include en (English), fr (French), de (German), es (Spanish), pt (Portuguese), ja (Japanese), and zh (Chinese).
Examples
Incorrect: Content in French, but lang set to English
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Mon site</title>
</head>
<body>
<h1>Bienvenue sur notre site</h1>
<p>Nous sommes ravis de vous accueillir sur notre plateforme.</p>
</body>
</html>
This triggers the warning because the validator detects French content but sees lang="en".
Fixed: lang attribute matches the content language
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Mon site</title>
</head>
<body>
<h1>Bienvenue sur notre site</h1>
<p>Nous sommes ravis de vous accueillir sur notre plateforme.</p>
</body>
</html>
Handling mixed-language content
If your page is primarily in one language but contains sections in another, set the lang attribute on the <html> element to the primary language and use lang on specific elements for the other language:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Our Global Site</title>
</head>
<body>
<h1>Welcome to our site</h1>
<p>We are glad you are here.</p>
<blockquote lang="fr">
<p>La vie est belle.</p>
</blockquote>
</body>
</html>
This tells assistive technologies that the page is in English, but the blockquote should be read using French pronunciation rules. The validator should not flag this as a mismatch because the majority of the content is in English.
This validation issue indicates that your HTML document does not specify a language for its content. Specifying the document’s language is important for accessibility, search engines, and browser behavior.
To fix this, you need to add the lang attribute to the <html> element, indicating the primary language of the document. For example, if your document is written in Spanish, you should set the lang attribute to "es".
Here’s how to do it:
Original HTML (without lang attribute)
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mi Sitio Web</title>
</head>
<body>
<h1>Bienvenido a mi sitio web</h1>
<p>Este es un párrafo en español.</p>
</body>
</html>
Updated HTML (with lang attribute)
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Mi Sitio Web</title>
</head>
<body>
<h1>Bienvenido a mi sitio web</h1>
<p>Este es un párrafo en español.</p>
</body>
</html>
Explanation
- The lang="es" attribute specifies that the primary language of the document is Spanish.
- Setting the lang attribute helps screen readers and other assistive technologies to better interpret the content.
- It also provides crucial information for search engines and browsers, improving the accessibility and search engine optimization (SEO) of your website.
If you need to specify a regional variation of Spanish, you can use values like lang="es-ES" for Spanish as used in Spain, or lang="es-MX" for Spanish as used in Mexico.
Example with Regional Variation
<!DOCTYPE html>
<html lang="es-MX">
<head>
<meta charset="UTF-8">
<title>Mi Sitio Web</title>
</head>
<body>
<h1>Bienvenido a mi sitio web</h1>
<p>Este es un párrafo en español de México.</p>
</body>
</html>
By adding the lang attribute with the appropriate value, you’ll resolve the W3C HTML Validator issue.
Specify the language of your HTML document using the lang attribute on the <html> element instead of using a <meta> tag for the language.
The HTML5 standard encourages specifying the primary language of a document using the lang attribute on the <html> element. The lang attribute should be set to a valid language code, such as en for English or fr for French. Using a <meta> tag to declare the document language is considered obsolete because the <meta> tag cannot convey element-specific language information. The lang attribute is more versatile and directly associates the language with the HTML document structure itself. This approach aligns better with accessibility requirements and helps user agents understand and render the content appropriately.
Here is how you should specify the language using the lang attribute:
Correct usage with lang attribute:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Document with Language Specification</title>
</head>
<body>
<p>This document is written in English.</p>
</body>
</html>
Incorrect usage with <meta> tag:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="en">
<title>This usage is considered outdated</title>
</head>
<body>
<p>This should not be done in HTML5.</p>
</body>
</html>
By defining the language with the lang attribute directly in the <html> tag, you improve the document’s compliance with modern standards and enhance the accessibility and internationalization aspects of your web content.