HTML HTML Basics Structuring Your Content Semantic HTML: <header>, <footer> and <section>

"All content lying inside the <body> element is part of a section." - that's what MDN says.

Does it mean that all content between <body> and </body> should be in <section>'s. Because in the next lessons I saw paragraph <p> that is inside the <body> but not part of the any section. Should I put all content in sections all it just a matter of web developer preference?

1 Answer

Abraham Juliot
Abraham Juliot
47,338 Points

Hi Andrei, We can have a page with no <section> tags. Some web developers may consider it a matter of preference, but using the correct tags to markup content has many benefits. Check out this article on the topic:

"By using HTML tags that have meaning, you create pages that impart more information than by just surrounding everything with <div> tags."

Regarding when to use the section element, MDN has some useful info. In short, use the <section> tag if there is not a more specific semantic element to represent the content. For example, if the content is only a paragraph, the <p> tag should directly contain it over a <section> tag.

Thank you for the links in your answer. I have bookmarked them. Thet are very helpful