What is the HTML header?

When working with a site, the first of the tags that a programmer encounters in HTML is <header>. When using it without attributes, differences in comparison with other tags are not visible, which raises the question of possible reasons for its use.

How and where to use?

The HTML <header> tag is an introduction to some section of the document. It is optional and is usually written at the top of the page section. From English, the "tag" is translated as "heading", but in Russian slang the word "cap" is more often used. Usually this tag is used at the top of the page where the site’s name and logo are located, as well as an auxiliary menu. However, one can often find its use in section headings.

html header

In HTML, <header>, like a number of other tags, appeared only in the 5th version of the markup language. Therefore, not all browsers handle it correctly. The language specification assumes that the tag contains the title of the section (h1-h6) or page, as well as auxiliary elements necessary in the "header" of the site, including banners, a contact data block, and others. Like most tags in HTML, <header> should have its own "closing pair" - </header>, indicating the end of the properties of this tag. If you want to adjust the site title to your personal design type, you can use a number of attributes for the tag to determine its style.

Examples of using

The practice of working with a tag will allow you to fully understand the principles of <header>. HTML examples of its use can be found on almost every major site. On them, it is usually used to indicate the header.

header html examples

One of the ways to set the "header" of the site using the <header> tag is the following example:

<header>

<h1> HTML5 </h1>

</header>

In addition to the title, you can also add any desired elements and tags, with the exception of <footer>. He is responsible for the page footer and cannot be present in the "header" of the site. If this element is found inside the title tag, the site will load incorrectly.

Source: https://habr.com/ru/post/K12075/


All Articles