Difference between <div>, <section> tag | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Difference between <div>, <section> tag

I've been trying to figure out the difference between these three tags on different forums online. Usually this is the explanation : section tag is used to explicitly contain elements such as headers and footers and chapters and the div tag is used as a css hook. could someone please elaborate??

22nd Jun 2018, 7:28 AM
Vivek Karthik
Vivek Karthik - avatar
1 Answer
+ 2
Hello, Vivek Karthik ! <section> means that the content inside is grouped (ie, belongs to the same topic) and should be displayed as an entry in the page outline. <div>, on the other hand, does not pass any value, except any found in its attributesclass, lang and title. So no: using <div> does not define a section in HTML. From the specification: <section> The <section> element represents the general section of the document or application. The section in this context is a thematic grouping of content. Each section must be identified, usually by including the header (element h1-h6) as a child of <section>. Examples of sections are chapters, various tabs in the tabbed dialog, or numbered sections of abstracts. The home page of websites can be divided into sections for introduction, news and contact information. The <section> element is not a common container element. When an element is needed only for styling or for the convenience of writing scripts, authors are advised to use the <div> element.
22nd Jun 2018, 7:35 AM
Alexander Sokolov
Alexander Sokolov - avatar