I have the following code:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
</body>
</html>
On the one hand, I have the following line:
<html lang="en" dir="ltr">
I understand that lang refers to the language, but what does the dir attribute refer to? In the direction of what?
On the other hand, the following line also catches my attention:
<meta charset="utf-8">
What does utf-8 refer to?
Good afternoon:
In your example the label
lang
document will containdir
is used to specify the orientation of the textexample:
the label:
charset="utf-8"
is used to specify the character encoding that the document will contain .lang
anddir
they are part of what is known as global attributes of HTML and XML documents, as indicated in section 3.2.5. Global attributes of W3C Recommendation.The official definition is this:
It should be said that
dir
it can also be used at the level of particular elements of the document, for example:Regarding the line:
<meta charset="utf-8">
what it does is define an attribute that belongs to the meta data content group , defined in section 3.2.4.2.1. W3C Recommendation metadata content .Be careful not to believe that all items in this group are tagged
meta
. It is not like that, itmeta
is part of the group of elements of the meta content type , among which are alsobase, link, title, script, style...
We are then going to define
meta
as an element and thus complete the answer:It should be said that the attribute
charset
is important for the presentation of pages, especially for handling accents and special characters. Sometimes, if this attribute is not handled well, the accents appear in the content replaced by other strange characters or by the inspector character.dir
attributeThe label:
-Lang:en=> exactly refers to English -dir=>ltr=>It means left to right and is used for languages that are written from left to right (such as English, Spanish, Portuguese for example) and in the opposite direction rtl is used (for example as the Arabic that goes from right to left)
-charset="utf-8"=>In HTML5 the default encoding if nothing is specified is UTF-8. However, it is the browser that ultimately decides which encoding to use. To avoid incorrect display in some browsers or misconfigured browsers, it is recommended to always include the charset meta tag. Important UTF-8 to display ñ or accents.