Diffference of lang and meta charset in html

1

Hello, I'm doubtful about the difference between the <meta lang="pt-br"> and <meta charset="utf-8"> settings. Thanks for the help

    
asked by anonymous 20.02.2018 / 15:35

1 answer

7

Both attributes have no relation at all, each has a goal.

The lang= attribute is only for specifying for BOTs and related what 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>

It indicates to the bots and the like that the first <p> is in Portuguese and the second one in English, that is to facilitate the life of the BOTs (or any other type of client software ). / p>

Of course, if you set the <html lang="(idioma)"> tag to inform you that the whole page is in a certain language.

Now the charset= attribute used in the <meta> tag, like this:

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

or the meta-tag:

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

They are used to define the coding that the page uses, type iso-8859-1 or utf-8 (there are others), the encoding type is not related to language, but to the character system it will use, and this same character system can be used by many languages, such as utf-8 , note that charset will set the entire page, ie you can not use two charsets on the same page , as I explained in this answer:

20.02.2018 / 15:43