<分区>
我目前正在清理我的个人博客,并试图使 HTML 正确地遵守 HTML 标准。博客结构简单。我有一个链接到博客文章的主页和每个博客文章的页面。
用于博客文章页面。我不确定我是否应该使用 <main>
或 <article>
标记来包装所有内容。
我要么使用
<html>
<body>
{ heading, navigation, etc. }
<main>
<h1>{title}</h1>
<time datetime="{publish date}">{human readable publish date}</time>
{content}
</main>
</body>
</html>
或
<html>
<body>
{ heading, navigation, etc. }
<article>
<h1>{title}</h1>
<time datetime="{publish date}">{human readable publish date}</time>
{content}
</article>
</body>
</html>
如果我阅读 HTML specification对于 <article>
正确地,
使用 <main>
似乎是更好的选择,因为 <article>
<main>
用于分隔 HTML 文档的独立自包含部分用于指示文档的主要部分或文档的主要部分。
我犹豫的原因是因为<article>
适用于 <time>
允许我指定帖子发布时间的元素。
来自 MDN(https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article):
The publication date and time of an element can be described using the datetime attribute of a element. Note that the pubdate attribute of is no longer a part of the W3C HTML 5 standard.