lang difference and meta charset in html

Asked

Viewed 1,840 times

2

Hello, I’m in doubt as to the difference between the definitions <meta lang="pt-br"> and <meta charset="utf-8">. I appreciate the help

  • 1

    Lang is only to specify for Bots and the like which language the site is likely to use, that is to make it easier, charset is to define the encoding the page uses, type iso-8859-1 or utf-8 (there are others). Both have no relation.

  • Charset is an abbreviation of "Character set" i.e., "character set" the UTF8 encompasses a huge group of Characteres https://en.wikipedia.org/wiki/UTF-8 characters that can be used in English, Spanish, EN :) etc..

1 answer

8

Both attributes have no relation, each has an objective.

The attribute lang= is only to specify for bots and the like which is the likely language of the page or a specific HTML element, for example on the same page:

<!-- irá informar que esta em português, independente de região -->
<p lang="pt">olá mundo</p>

<!-- irá informar que esta em inglês, independente de região -->
<p lang="en">Hello world</p>

<!-- irá informar que esta em português do Brasil -->
<p lang="pt-BR">olá mundo</p>

<!-- irá informar que esta em inglês britânico -->
<p lang="en-GB">Hello world</p>

Indicates to bots and the like that the first <p> this in Portuguese and the second in English, ie is to facilitate the life of Bots (or any other type of client software).

Of course if you define yourself in the tag <html lang="(idioma)"> to inform that the entire page is in a given language.

Already the attribute charset= used in tag <meta>, thus:

<meta charset="(codificação escolhida)">

or the metatag:

<meta http-equiv="Content-Type" content="text/html; charset=(codificação escolhida)">

They serve to define the encoding that the page uses, type iso-8859-1 or utf-8 (there are others), the type of encoding has no relation with language, but with the character system that will use, and this same character system can be used by numerous languages, as is the case of utf-8, note that the charset will set the whole page, ie you cannot use two Charsets on the same page, as I explained in this reply:

Browser other questions tagged

You are not signed in. Login or sign up in order to post.