Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should the header and footer tags be inside the main tag

Tags:

html

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"?

like image 755
panthro Avatar asked Dec 09 '13 12:12

panthro


People also ask

What should be inside main tag?

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.

Should footer tag be inside body tag?

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.

Can you have a header in a main?

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.

Where do header and footer tags occur?

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.

What is a <footer> tag?

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.

Is header and footer part of the content of the page?

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.

What is the use of header tag in HTML?

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.

What is a <footer> element in HTML?

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.


2 Answers

From HTML5doctor article The main element @Gaby aka G. Petrioli

tl;dr

Rule of thumb :

  • only one <main> per page ;
  • top-level element (in most cases) ;
  • don't put your site's header/menu/footer (repeated content) in your <main>.
  • can hold article header/footer if specific.

Purpose

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:

Specs says

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.

Header/footer

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).

Continue to use 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.

like image 78
Édouard Lopez Avatar answered Sep 24 '22 03:09

Édouard Lopez


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.

like image 31
janfoeh Avatar answered Sep 23 '22 03:09

janfoeh