When do you use <section> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

When do you use <section>

Hi, Ive never used <section> Tag, can somebody tell me for what reason it exists. Thanks

10th Oct 2022, 6:19 AM
Omar
Omar - avatar
2 Answers
+ 2
<section>: The Generic Section element The <section> HTML element represents a generic standalone section of a document, which doesn't have a more specific semantic element to represent it. - mdn web docs https://i.pinimg.com/originals/1f/a9/a5/1fa9a502eb1158eb767f4730f1c8698a.png
10th Oct 2022, 6:24 AM
Chris Coder
Chris Coder - avatar
+ 2
Hi, <section> is a semantic element in HTML that represents a thematic group of related content within a document. It can be used to divide your document into meaningful parts, such as chapters, topics, features, or sections of a web page. It helps to organize your document structure and make it more accessible and understandable for both humans and machines. For example, you could use <section> to wrap a group of related articles, a blog post with its comments, a product description with its reviews, or a gallery of images. Each <section> should have a heading that describes its main topic or purpose, and you can nest <section> elements inside other <section> elements or other semantic elements, such as <article>, <aside>, <nav>, or <main>. However, you should not use <section> for generic containers or styling purposes, as there are other elements, such as <div>, for that. You should also not use <section> as a replacement for <header> or <footer>, as they have their own specific meanings and roles in the document.
10th Oct 2022, 9:07 AM
Paul