html – What are the differences between the "pt" and "pt-BR" values ​​of the lang attribute?


In the tests, I couldn't notice any difference between the two values. Anybody know? To help: the first two characters of the value define the Language Code Reference (ISO 639-1) and the last two, after the separator, identify the Country Code Reference (ISO 3166-1). But when we omit the Country Code, what actually changes? I don't see anything different in IE and Chrome browsers and generally developers don't report the country.


I'll summarize well, pt indicates Portuguese, regardless of country/region as:

Source: Which countries and regions speak Portuguese?

  • Brazil
  • Portugal
  • Sao Tome and Principe
  • Angola
  • Mozambique
  • Cape Green
  • East Timor
  • Guinea Bissau
  • Equatorial Guinea
  • Macau (Macau)

When we use pt-BR we indicate Brazilian Portuguese, just as pt-PT indicates Portuguese from Portugal.

Portuguese as well as English has variations in different countries, the indication of pt-BR , pt-PT , pt , en , en-US , en-GB do not interfere in the HTML , they are just values ​​to inform which language is found, for example some browsers have page language detection and they can pass it on to some plugin, or a plugin (add-on/extension) can use the attribute directly.

If you put the URL of the page that uses this attribute in it will detect that that <div lang="pt-BR"></div> uses Brazilian Portuguese (although google doesn't differ very much both).

Others that can generally use this attribute are search engines like Google, Bing, Yahoo, Baidu. Search engines use these attributes to deliver pages of the regional and language preference of a person who is searching.

Now speaking only of HTML, the lang attribute regardless of its value, pt or pt-BR does not change at all, the idea of ​​using it is to standardize and indicate the data types for those interested, if there is no plugins attribute, google translator or search engines have more difficulty detecting the language and region of the page.

Scroll to Top