html - Should I use <main> or <article> for a blog post? -
i'm cleaning personal blog , i'm trying make html more semantic. blog structure simple. have home page links blog posts , page each blog post.
for blog post pages. i'm not sure if should use <main> or <article> tag wrap of content.
i either use
<html> <body> { heading, navigation, etc. } <main> <h1>{title}</h1> <time datetime="{publish date}">{human readable publish date}</time> {content} </main> </body> </html> or
<html> <body> { heading, navigation, etc. } <article> <h1>{title}</h1> <time datetime="{publish date}">{human readable publish date}</time> {content} </article> </body> </html> using <main> seems better option because <article> meant separate independent self-contained parts of html document while <main> meant indicate main part of document or meat of document.
the reason i'm hesitating because <article> works <time> element allow me specify when post published.
from mdn (https://developer.mozilla.org/en-us/docs/web/html/element/article):
the publication date , time of element can described using datetime attribute of element. note pubdate attribute of no longer part of w3c html 5 standard.
(note 2 examples create different document outline.)
use both. elements serve different purposes , work fine together.
<main> <article> </article> </main> if can use 1 element reason, go main, because use of heading creates implicit section (where article make section explicit), , article-related features (like address , bookmark) work if body nearest section. note there no time-related feature article anymore (early html5 drafts had pubdate attribute, offered such feature, got removed).
Comments
Post a Comment