Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the main tag in HTML5 ? How does it differ from body tag? [duplicate]

Tags:

html

I have a lot of confusion around main tag of HTML. It describes content of the page but so does body. There should be only one main tag in the page. The body tag should also have one appearance in HTML. What is the difference between these two tags ? Which elements can be nested between main tag and which can't? How does this tag change it's nature to flow content and palpable content ?

like image 312
Sandesh Koirala Avatar asked Jun 28 '19 08:06

Sandesh Koirala


1 Answers

Differences between main and body:

main:

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.

body:

The body element contains all the contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc.

An easy example, the footer element; you should put it inside the body, but outside the main, as you will do with your menu, or sidebar.

like image 183
Josep Vidal Avatar answered Oct 18 '22 10:10

Josep Vidal