My intention was to reduce container wrapping to 2 main blocks by using the body tag as a first container. Then within the main tag 2 subcontainers. The header tag will be used as a container for icons, text and search field. Hence I find the use of h1 tag limiting.
My intention is to make as accessible as possible. But this is a huge subject that is my next level. Now I focus on reducing code and make it as readable as possible.
I read this: " <main> is a very important semantic element that I used in the markup above that I haven’t covered yet and that is the <main> element. The <main> element represents the primary content of the page. It is not supposed to feature any side bars or navigation elements in it."
Consider this advice, my example should be this instead?
I kind of thought section was almost interchangeable with a div, but I don’t think that is the case. Read this from MDN
As an example, a navigation menu should be wrapped in a <nav> element, but a list of search results or a map display and its controls don’t have specific elements, and could be put inside a <section> .
For instance on my site I was thinking, much like with the map display, maybe the carousel could be wrapped in a section, as there isn’t a more specific tag for that.
From what I also gather you should not apply styles to sections, to my understanding they are not far removed from using a comment.
So I would think based on that your section could actually just be a div e.g. <div class='container'>, but please don’t take my word for gospel. As I say hopefully someone else here can better point you in the right direction.
AFAIK semantic tags are interchangeable with divs - technically. Just more clean. And the only rule I have found is mandatory is that no more than ONE main tag on a page. I have also found the rules (if there are any clear) differs from who you ask.
I think the <article> tag should be brought into this discussion.
In the HTML LIving Standard the <article> element is described before the <section> element. I note however that in the W3C Working Draft that the <section> element is described before the <article> element. I get the impression that the <section> tag was intitially intended as a way to divide long articles but is now recognised as a way to divide web page content.
We ought to use the <article> element where it is more appropriate than the <section> element.
My understanding is that <section> elements can contain <article> elements and <article> elements can contain <section> elements!
#1: You tell me, is your head part of your body?
The body is the content of the page. Its sole purpose is to be a container for the content.
A section is a generic identifier for a section of a document that is part but not whole. An article is a self-contained part of a document that could be distributed on its own.
Given the previous specification, it very well could be. If you section was for example, a news feed, it may contain several articles.
The idea is that sections are the chapters of your page; the table of contents would list each section.
Different purposes, but same effect. A div is encouraged when an element is needed for styling or scripting. If you are creating sections or articles just for that purpose, you should be using a div instead.
While that is fine in most cases there can be situations where it’s not so fine. If for example you are giving the body a width or max-width then the body background colour would not stay at that width as it propagates to the html element. There is also the issue of overflow and how that is handled when the body width is reduced.
Most sites will require a max width anyway as 100% on a wide monitor like my 27” iMac is almost unusable.
It may be that you are putting the max width on the inner containers but that means managing all the separate elements individually which can be impracticable .
For those reasons and for the sake of adding one div as a wrapper I would advocate leaving the body alone in most cases. It’s not wrong to use the body as a wrapper but just be aware that the body element is slightly special.