Before HTML gained these elements, every page was a stack of divs with class names like header and content, understood by the person who wrote them and by nobody else. The structural elements replaced that convention with something the browser understands.
The basic skeleton
<body> <header> <a href="/">Coding Tutorials</a> <nav aria-label="Main"> ... </nav> </header> <main> <h1>Page title</h1> ... </main> <footer> <p>© 2026 Coding Tutorials</p> </footer> </body> This is the shape almost every page takes. What the elements add over divs is that each becomes a landmark, a named region a screen reader user can jump to directly.
The main element
Main contains the primary content of the page: the part that is unique to it, excluding the navigation, the site header, the footer and any sidebar repeated across pages.
There should be exactly one per page. The specification permits additional ones only if all but one are hidden, which is a narrow case relevant to single page applications. In ordinary use, one is the rule.
Main must not be nested inside an article, an aside, a header, a footer or a nav. It is a top level region, and placing it inside one of those is a validation error as well as a structural confusion.
It is also the natural target for a skip link, which is the single most valuable use of the element. A skip link pointing at the main content lets a keyboard user bypass the navigation on every page, and without a main element there is nothing obvious to point it at.
Header is contextual
This is the part people get wrong. A header element does not always mean the site header. Its meaning depends on where it sits.
As a direct child of the body, it is the banner for the whole page and becomes a banner landmark. Inside an article or a section, it is the introductory content for that piece specifically, and it is not a landmark at all.
<article> <header> <h2>Understanding specificity</h2> <p>Published <time datetime="2026-06-20">20 June</time></p> </header> <p>...</p> </article> That header groups the title and metadata of the article. It is entirely correct and has nothing to do with the top of the page.
Footer works the same way
At body level, footer is the site footer and becomes a contentinfo landmark. Inside an article it holds that article's closing information: the author, tags, a licence note.
A page may therefore contain several footers, and only the top level one is a landmark. This is by design and is worth understanding before someone reports it as a bug.
What belongs in each
A page level header usually holds the site name or logo, the primary navigation, and sometimes a search field or account controls. It is not obliged to contain a heading, which is a common misconception, and a site name marked up as a level one heading on every page is usually a mistake, since the level one heading should describe the page rather than the site.
A page level footer typically holds a copyright notice, secondary navigation, contact details and legal links. Contact details specifically have their own element, the address element, which is intended for the contact information of the nearest article or of the page as a whole rather than for postal addresses in general.
Main holds everything unique to the page. A useful check is whether the content inside it would be identical on another page of the site. If it would, it probably belongs in the header, footer or an aside instead.
These elements have no styling
Header, footer and main are all block level elements with essentially no default styling beyond that. They do not create a layout, they do not add spacing, and they do not position anything.
Switching a div to one of them changes nothing visually, which is what makes the change safe to make on an existing site. The benefit is entirely in what the markup communicates.
Do not overuse them
A header inside every card, a footer on every list item, and a main wrapped around each column all dilute the structure rather than improving it. The elements mean something specific, and applying them loosely makes the page harder to interpret rather than easier.
Where you simply need a container to hang styles on, a div remains correct.
Checking the result
Browser extensions display the landmark structure of a page as a list. Running one over your layout takes seconds and shows immediately whether you have a banner, a main region and a contentinfo, or whether the page is a flat run of unnamed containers.
The test to apply is whether someone could navigate your page using only that list. If the regions are present and sensibly named, they can. If everything is generic, the list is empty and the page offers no shortcuts at all.