I thought that es_ES is the lang attri" /> I thought that es_ES is the lang attri" /> I thought that es_ES is the lang attri"/>

What is the right lang attribute to write in the html tag?

88 views Asked by At

I have a site with this code:

<!doctype html>
<html lang="es_ES" prefix="og: https://ogp.me/ns#" class="no-js">

I thought that es_ES is the lang attribute for spanish of Spain but when I check the URl in pagespeed and says:

element does not have a valid value for its [lang] attribute. Specifying a valid BCP 47 language helps screen readers announce text properly. Learn how to use the lang attribute.

I have read that docuemnt and says es_es, en_UK, fr_FR ( for Uk and France)

I have changed to es_es and the same issue

any idea about this issue?

This is the pagespeed url:

https://pagespeed.web.dev/analysis/https-distron-es/eg6bzmrqpj?form_factor=mobile

1

There are 1 answers

0
Barry Pollard On

The document doesn't say to use es_es (with an underscore) but to use es-ES (with a dash). Using that correct value passes the accessibility audit. It also passes when all in lowercase (lang="es-es"), but convention is to use lowercase for the language and uppercase for the country.

However, unless you are specifically aiming for your Spanish at people from Spain (as opposed to general Spanish speakers, including those in South America, for example), lang="es" should be sufficient.