探索带有 Pubdate 属性的 Time 标签
在这一步中,你将学习 pubdate
属性,这是 <time>
标签的一个特殊布尔属性,用于指示文章或博客的发布日期。尽管它在 HTML5 中已被视为过时,但了解其历史用法有助于深入理解语义化 HTML。
在 WebIDE 中打开 event-schedule.html
文件,并修改内容以包含一个带有 pubdate
属性的博客文章示例:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Tech Blog Post</title>
</head>
<body>
<article>
<h1>Latest Tech Insights</h1>
<header>
<h2>HTML5 Semantic Elements</h2>
<p>
Published on
<time datetime="2023-06-20" pubdate>June 20, 2023</time>
</p>
</header>
<p>In this article, we explore the semantic meaning of HTML5 tags...</p>
<footer>
<p>
Updated on
<time datetime="2023-06-22">June 22, 2023</time>
</p>
</footer>
</article>
</body>
</html>
关于 pubdate
属性的关键点:
- 它是一个布尔属性(不需要值)
- 用于指示文章的发布日期
- 在 HTML5 中已被弃用,但仍被许多浏览器支持
- 通常用于
<article>
标签内
在 Web 浏览器中查看时的示例输出:
Latest Tech Insights
HTML5 Semantic Elements
Published on June 20, 2023
In this article, we explore the semantic meaning of HTML5 tags...
Updated on June 22, 2023
注意:尽管 pubdate
现在被视为过时,但它展示了语义化 HTML 的演变以及提供机器可读日期信息的重要性。