I'm using the main
tag - should I put my header and footer tags inside the main tag or should they be separate?
Also, does the main tag need role="main"?
The <main> tag specifies the main content of a document. The content inside the <main> element should be unique to the document. It should not contain any content that is repeated across documents such as sidebars, navigation links, copyright information, site logos, and search forms.
HTML5 <footer> Tag The <footer> tag in HTML is used to define a footer of HTML document. This section contains the footer information (author information, copyright information, carriers, etc). The footer tag is used within the body tag.
For example there's a header and a main inside of the body and there's also a header inside of the main tags. Short answer, as you describe it, yes. Any section of a page can be considered a document body in its own right, thus affording it the full range of markup given its parent.
A <footer> is generally found at the bottom of a document, a section, or an article. Just like the <header> the content is generally metainformation, such as author details, legal information, and/or links to related information.
The <footer> tag defines a footer for a document or section. A <footer> element typically contains: You can have several <footer> elements in one document. Tip: Contact information inside a <footer> element should go inside an <address> tag. The numbers in the table specify the first browser version that fully supports the element.
And both header and footer are part of this content. Show activity on this post. I see what you are trying to do, you are trying to use the <body> tag as the container for the main content of the page.
The tag can also be used as a header for an element within a page. For example, an article that is a part of the page. In practical we could have a <div> for an article within a page, and a <header> tag as the first element within the <div> defining the header for that article. No element can directly contain two header elements.
More "Try it Yourself" examples below. The <footer> tag defines a footer for a document or section. A <footer> element typically contains: You can have several <footer> elements in one document. Tip: Contact information inside a <footer> element should go inside an <address> tag.
From HTML5doctor article The main element @Gaby aka G. Petrioli
Rule of thumb :
<main>
per page ;<main>
.The primary purpose of <main> is to map ARIA’s landmark role main** to an element in HTML. This will help screen readers and other assistive technologies understand where the main content begins. The W3C spec describes as representing:
Here is what the draft spec says:
The main content area consists of content that is directly related to or expands upon the central topic of a document or central functionality of an application.
Exclude site's header/footer/menu:
excludes content that is repeated across a set of documents such as site navigation links, copyright information, site logos and banners and search forms (unless the document or applications main function is that of a search form).
role='main'
But as a side note to this article Steve Faulkner write:
You should still use the ARIA role until all browsers map the role to the <main> element.
Since it represents the central part of your page - the "beef" if you want - and headers and footers are considered adjacent content, I would argue that headers and footers should not be child elements.
In theory, yes, using <main>
does mean the same as adding role="main"
. But as it has limited support at the moment, using <main role="main">
is recommended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With