When do I put headings inside a header
element? I can't understand it, sometimes it seems to me that each heading has to be between header
tags.
Let's take this sidebar as example :
How to code it?
<aside>
<header>
<h1>How to format</h1>
</header>
</aside>
or
<aside>
<h1>How to format</h1>
</aside>
<header>
give us some great added semantic value in order to describe the head of a section. You can use multiple headers in a web page, each of which will then become the<header>
for that section of the document. So, using a<header>
depends on the complexity of the section. The more complex it is, the more necessary the header element becomes. a<header>
typically contains at least (but not restricted to) one heading tag (<h1> – <h6>
).hope it helps
See the specification of the
header
element:So you can have many header elements in a page (it's not limited to the top of the page), and you can use it around headings, but it's optional. This means both of your examples are correct.
The header tag is for what displays at the top of the page of the page-what is sometimes called the banner. So put your h1-h6 tags in it when they are in the banner of your page.
Tags like header and footer are basically just div's renamed for organizational sanity. In the future search engines and browsers may look for header and footer tags to help them process and display information better. For now, it lets you avoid staring at a bunch of div tags.
Instead of this...