In this article, we will see what the 7 tags do and how they are used, along with the 3 most basic tags that are necessary when starting HTML and even the 4 html tags that we will use on the way. If you are new to coding and don’t have any information yet, you may want to read my previous article What is HTML and what does it do?
1. <!DOCTYPE html>
and <html>
Tag
At the very beginning of every HTML file is the declaration <!DOCTYPE html>
. This tells the browser that the document was written using HTML5. It is immediately followed by the <html>
tag. This tag wraps all your HTML code and indicates the beginning and end of an HTML document.
<!DOCTYPE html>
<html>
<!-- Here are the head and body tags -->
</html>
2. <head>
Tag
The <head>
tag contains information about the page, usually non-visual. This includes elements such as the page title, character set, linked style files (CSS) and meta tags. For example, <title>
tag is located in this section and determines the tab title of the web browser.
<head>
<meta charset="UTF-8">
<title>Title of this Page</title>
<!-- Other header elements -->
</head>
3. <body>
Tag
The <body>
tag contains all the content shown to the user. Texts, images, links, lists, tables and more are included in this section. In short, everything you want to see in the browser is written inside the <body>
tag.
<body>
<h1>This is a title</h1>
<p>This is a paragraph.</p>
<!-- Other contents -->
</body>
Use in Combination
An HTML document is created by combining these three parts. Here is an example of a basic HTML structure:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Sample Page</title>
</head>
<body>
<h1>Hello World!</h1>
<p>Welcome to learn HTML.</p>
</body>
</html>
By building on this simple structure, you can create more complex and functional web pages. Understanding this basic structure and tags while learning HTML will create a solid foundation for the next steps.