why I use “main” instead of “body” tag?
Welcome to the forums.
We would not use it instead of BODY, but as a child of the body.
body header main footer
Isn’t “main” used outside of “body” in the given example sir?
In well formed markup, the
<body></body> is the outermost content container. It’s sibling is the
<head></head> element that contains all the metadata.
<footer></footer> are all children of the body, at the very least, though they could be children of
<article></article>, which are also descendents of BODY.
If we look at the specifications we will find that HEAD and BODY are optional elements, though we don’t see this in practice for a full blown web page. Typically page fragments that are merged with the page via AJAX are stored as plain HTML, but the following is valid for simple documents…
<html> <div> <h1>heading<h1> <p>textual content</p> <p>textual content</p> <p>textual content</p> <p>textual content</p> </div> </html>
If our document uses
<html></html> to wrap it, then it is HTML that it contains.
Edited May 13, 2020
See following post concerning error in above markup.
at this code when you see
That only took five months for someone to point out. Good eyes!