The term “tag” literally means “label”. A label is used to mark or identify something, like a price tag in a market for example.
In HTML5, tags serve the same purpose: to mark elements. That is, to determine where an element starts and where it ends. This is very appropriate, after all “HTML” means Hypertext Markup Language.
There are two types of tags: 1) those that need closing and 2) those that close themselves. Let’s get to know them now.
1 - Tags that need closing
To create a tag, we need to define a less than sign (<), the name of the tag, and finally a greater than sign (>).
To close this same tag, simply define a less than sign (<), a slash (/), the name of the tag, and a greater than sign (>).
Between the opening and closing tag will be the content of the tag. Example:
In red are the opening and closing tags and in yellow is the content of the tag.
When a tag is interpreted in the browser, it turns into an HTML element.
2 - Self-closing tags
Some tags do not need a closing tag. In this case, in the opening tag, after defining the name of the tag, we already place a slash (/), making its closure clear. Example:
In red is the opening tag and the closing slash at the end of it.
Self-closing tags will not have content.
We realize that it’s quite simple to create a tag, don’t you agree? They can be simple to create, but they are also very powerful, as they are one of the foundations of the HTML language, which also makes them one of the foundations of the Modern Web. :)
There is a Chinese proverb that says: “A long journey always begins with the first step.” Likewise, no matter how large a website or system may be, it will always start with a small tag.
Until the next article!
Did you like this article?
Would you like to learn more about HTML5? Then sign up for our Complete HTML5 Course, which you can access at this link https://hcode.com.br/cursos/HTML5. Learn all the tags and attributes of this language, through practical examples, with the help of the Hcode teaching method ;)