3

I've done a few searches for my answer to my question, but I can't seem to get a straight answer other than the cut-and-pasted responses which DO NOT answer my question.

My question is, "Can I use the <main> tag in different pages of my website?"

The websites I've researched state:

"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.
Note: There must not be more than one <main> element in a document. The element must NOT be a descendant of an <article>, <aside>, <footer>, <header>, or <nav> element."

So...
I understand the <main> tag specifies the main content of a document.
I understand that the content inside the <main> element should be unique to the document.
I also understand it should not contain any content that is repeated across documents such as sidebars, navigation links, copyright information, site logos, and search forms.

And here is where my question arises...what does it mean by "document?"

Does the word "document" mean:

A) I could use it in my index.html, about_us.html and contact.html, but only once in each of those pages.

or does it mean

B) I cannot use <main> within other pages of the website. Which would mean that if I use it on my index.html then I would not be able to use it in my other pages like about.html or contact.html...?

Websites researched:
https://www.w3schools.com/tags/tag_main.asp
http://blog.teamtreehouse.com/use-html5-sectioning-elements

Thank you for clarifying.

1 Answer 1

2

Yes you can use <main> tag in different pages of a website.

Answer A.

A document is short for HTML document, it means a valid html file. Not a html fragment.

There are 3 good uses for the <main>. It can help algorithms that scan web pages be more efficient. Quickly identify the main content, and as a consequence not process what is outside the main. It can be styled with a CSS rule. It can help users with screen readers.

Update: Inside work in progress, html specification, it is possible to have multiple <main>, as long as only 1 is visible.

https://w3c.github.io/html/grouping-content.html#elementdef-main

1
  • Thanks for clarifying this up for me. The word document was throwing me for a loop because I wasn't clear what the "document" consisted of and how it pertained to the entire project. Again, thank you.
    – Lexiriam
    Commented Aug 19, 2017 at 12:28

Not the answer you're looking for? Browse other questions tagged or ask your own question.