HTML参考手册
标签 | Elements
time
HTML标签(<time>
)表示是在24小时的时钟时间或在一个确切的日期公历(带有可选的时间和时区信息)。
内容类别 |
Flow content, phrasing content, palpable content. |
---|---|
允许的内容 |
Phrasing content. |
标记遗漏 |
没有; 起始和结束标签都是强制性的。 |
允许的父母 |
任何接受 phrasing content. 的元素。 |
允许ARIA角色 |
任何 |
DOM接口 |
HTMLTimeElement |
属性
像所有其他元素一样,此元素拥有可以使用通用属性。
datetime
该属性表示此元素的时间和日期,并且属性值必须是一个有效的日期格式,并可包含时间。 如果此值不能被解析为日期,元素不会有一个关联的时间戳.
使用说明
此元素用于以机器可读格式显示日期和时间。例如,这可以帮助用户代理提供将事件添加到用户的日历。
该元素不适用于无法计算特定日期的情况,也不适用于引入公历之前的日期(由于计算这些日期的复杂性)。
例子
Simple example
HTML
<p>The concert starts at <time>20:00</time>.</p>
Output
datetime
example
HTML
<p>The concert took place on <time
datetime="2001-05-15T19:00">May 15</time>.</p>
Output
规范
Specification |
Status |
Comment |
---|---|---|
HTML Living StandardThe definition of '<time>' in that specification. |
Living Standard |
No change from HTML 5.1 |
HTML 5.1The definition of '<time>' in that specification. |
Recommendation |
No change from HTML5 |
HTML5The definition of '<time>' in that specification. |
Recommendation |
Initial definition. |
浏览器兼容性
Feature |
Chrome |
Edge |
Firefox |
Internet Explorer |
Opera |
Safari |
---|---|---|---|---|---|---|
Basic Support |
62 |
(Yes) |
22 |
No |
49 11.5 — 12 |
7 |
datetime |
62 |
(Yes) |
22 |
No |
49 11.5 — 12 |
7 |
Feature |
Android |
Chrome for Android |
Edge mobile |
Firefox for Android |
IE mobile |
Opera Android |
iOS Safari |
---|---|---|---|---|---|---|---|
Basic Support |
62 |
62 |
(Yes) |
22 |
No |
49 11.5 — 12 |
4 |
datetime |
62 |
62 |
(Yes) |
22 |
No |
49 11.5 — 12 |
4 |
标签 | Elements相关
超文本标记语言,它通过标记符号来标记要显示的网页中的各个部分。网页文件本身是一种文本文件,通过在文本文件中添加标记符,可以告诉浏览器如何显示其中的内容(如:文字如何处理,画面如何安排,图片如何显示等)。浏览器按顺序阅读网页文件,然后根据标记符解释和显示其标记的内容,对书写出错的标记将不指出其错误,且不停止其解释执行过程,编制者只能通过显示效果来分析出错原因和出错部位。但需要注意的是,对于不同的浏览器,对同一标记符可能会有不完全相同的解释,因而可能会有不同的显示效果。