Skip to main content

HTML Guide

This document appears to be written in X. Consider adding “lang="y"” (or variant) to the “html” start tag.

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.

Learn more:

Related W3C validator issues