HTML Elements <section> vs <div> vs <article>
HTML Elements <section>, <div> and <article> are all block elements. But they have different semantics.
<section>
The <section> element represents a generic section of a document or application.
- A section, in this context, is a thematic grouping of content:
โ chapter
โ various tabbed pages in a tabbed dialog box
โ numbered sections of a thesis โฆ
- A Web siteโs home page could be split into sections for an introduction, news items, and contact information.
- The section element is not a generic container element. The section element is appropriate only if the contents would be listed explicitly in the documentโs outline. [Example A]
- A section typically with a heading.
<div>
The <div> element has no special meaning at all.
- It can be used with the class, lang, and title attributes to mark up semantics common to a group of consecutive elements.
- When no other element is suitable, the div element is used as an element of last resort. Otherwise, it leads to poor accessibility for reader.
<article>
The <article> element represents a independent item section of content. It must have a <h1> tag for title.
- Independent item section of content:
โ forum post
โ magazine article
โ newspaper article
โ blog entry [Example A]
โ user-submitted comment [Example B] โฆ
- In principle, content in the article element should be independently distributable or reusable.
Thatโs a wrap! Happy codesign today ๐ง๐ปโโ๏ธ๐ฟ
โจ๐ฃ Frontendly.io is helping people become a really good frontend engineer ๐ฟ, practice with real-world scenarios, and level up your front-end skills. Check it out! ๐