gpt4 book ai didi

持续时间的 HTML 时间标记

转载 作者:太空狗 更新时间:2023-10-29 14:57:38 27 4
gpt4 key购买 nike

我需要显示视频的时长。我应该使用 <time> 吗?还是应该像时钟一样仅用于显示时间?

示例

这是正确的 HTML5 吗?

<p>Duration: <time>3:30 min</time>.</p>

或者应该<time>只能在这种情况下使用?

<p>Good morning. The actual time is: <time>9:45</time></p>.

文档

MDN提出以下定义:

The HTML element represents either a time on a 24-hour clock or a precise date in the Gregorian calendar (with optional time and timezone information). This element is intended to be used presenting dates and times in a machine readable format. This can be helpful for user agents to offer any event scheduling for user's calendar.

但是,W3C中的定义有点不同,指的是持续时间:

Specifies the date or time that the element represents.

Value: Any one of the following:

  • (...)

  • a valid duration string as defined in the [HTML5] specification

Examples:

PT4H18M3S

4h 18m 3s

所以,我不确定我是否应该使用 <time>在这种情况下与否。有什么想法吗?

最佳答案

是的,您可以使用 time element持续时间。

但值必须是 valid duration string ,而“3:30 分钟”不是。

您可以使用 datetime attribute指定正确的值,并保留“3:30 min”作为元素内容,例如:

<time datetime="3m 30s">3:30 min</time>

关于持续时间的 HTML 时间标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31559103/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com