The header tag in HTML5
- 24-07-2022
- Trung Minh
- 0 Comments
In this article, I will show you how to use the header tag in HTML5, this is the tag used to declare the header header for a web page or articles.
If you look through a website built with HTML5, you will feel very confused, because the header tag is placed in many different places. But if you understand what it means, it will feel very easy.
1. What is the header tag in HTML5?
In HTML5, the header tag is used to declare the header ( header ) for articles, even the top of the web page. Do not confuse the header
tag with the head tag.
The header tag structure is as follows :
<header>...</header>
2. Can I use multiple header tags in HTML5?
The answer is absolutely yes. For example, in the page displaying the list of articles, you will use the article tag to declare each article, inside each article will declare an additional header tag to cover the title of the article.
<article> <header> <h2>Tiêu đề 1</h2> </header> <p>Mô tả bài viết 1</p> </article> <article> <header> <h2>Tiêu đề 2</h2> </header> <p>Mô tả bài viết 2</p> </article> <article> <header> <h2>Tiêu đề 3</h2> </header> <p>Mô tả bài viết 4</p> </article>
You can also use the header to declare the top part ( containing the logo and other basic information ) of the web page.
<body> <header> <h1>HTML5 Cho Người Mới Bắt Đầu Tại web888.vn</h1> </header> <nav> <ul> <li><a href="#">Home</a></li> <li><a href="#">Serie</a></li> <li><a href="#">Tutorial</a></li> <li><a href="#">Ebook</a></li> </ul> </nav> ... </body>
3. Write CSS for the header . tag
If you want to use CSS to style the header tag, use one of the two ways below.
Method 1 : Direct CSS.
<header style="background:red"> ... </header>
Method 2 : Use selector.
<style> header{ background:red } </style> <header> ... </header>
Note : If you do not want to use the header tag to declare this section, you can use the div tag instead.