众所周知,HTML 在 Web 开发领域不断发展,是全球流行的标记语言。据说Web开发人员需要更新和了解HTML元素。在这篇文章中,我们将学习一些重要的标签,称为时间标签。对于人类来说,读取多种形式的日期/时间很容易,但是对于机器来说,解析到那时的并不容易。进来了。这次标签定义特定的时间段并指定特定网页的日期和时间。因此,它们非常有用并且代表了人类可读的标签。这种人类可读的格式是一种有价值的互联网协议格式。 HTML 5 支持标签,但 HTML 4.01 版本不支持。
时间可以通过以下方式定义:
- 持续时间
- 24小时正确时间
- 公历日期
随着时间进步的好处,网页更加结构化,使搜索引擎可以轻松阅读 HTML 代码,以分析网页上的想法以及开发事件调度和任何与时间相关的事件功能的好处。例如,在搜索引擎中与时事相关联,这有助于通过视觉时间事件对当前网页进行更高的排名。
语法:
<time> 2020-01-28 </time>
使用基本日期时间属性可以为时间标签提供唯一的特定格式,因为它适用于计算机。
从上面的语法来看,
属性
属性在 HTML 中扮演着重要的角色。通过此 HTML 元素,用户可以灵活地在其工作中添加日程安排日期,并在各自的日历上添加生日提醒;另一个好处是搜索引擎可以给我们带来更好的搜索结果。该时间元素支持全局和事件属性;除此之外,一个重要的属性是日期时间。要显示“星期一”等值,请表示“星期五”日期时间属性。
下表说明了与此元素相关的属性及其描述:
Attribute Name | Description |
DateTime | It specifies a machine-readable input time of the element. |
Pubdate | It has a Boolean value that Specifies the publication date of the content. |
There are some different ways of representing the date-time attribute. The profile of ISO 8601 provides the standards which follow the ABNF notation. And the letters below ‘T’ and ‘Z’ should be declared in the Upper case.
1. Year and Month
Very Simple Format with the year before.
2019 – 08
2. Date Alone
1946-08-17
3. Date without Year
08-21
4. Only Time Display
13: 55: 30. 522
5. Date and Time
2014 – 08 -21T15:55
Here T is for separation between Date and Time.
6. Time Zone Format
It initiates with either plus or minus and, in some cases, ( : ) is replaced With the capital ‘Z’.
+ 08 : 05
7. Year and Week
Follow the corresponding number of weeks after the letter ‘W’ to represent a week.
2017 – W 20
8. Duration (with Two methods)
2w 3d 4 h 25 min 12.402s
Also, it supports global attribute along with this element like id, class, style and supporting event attributes like onabort, onfocus, onclick, onmousedown, onmouseout, onkeyup, onchange, ondrag, ondrop, onselect, onmessage, onscroll.
Examples to Implement HTML Time Tag
Using this tag, You can display the date or time without a datetime attribute. The following are some examples:
Example #1 – using a
Code:
<title> HTML Time Tag </title> <h2 id="HTML-Time-Tag-demo">HTML Time Tag demo</h2> <p> India celebrate as <time>2020-01-26</time> Republic day </p>
Output:
Example #2
Making a time element to the title attribute to show detailed information about the user in a nice human-readable or machine-readable format.
Code:
<h2 id="center-Date-Time-Example-center"> <center> Date Time Example </center> </h2> <h3 id="The-Stand-Up-Comedy-show-starts-at-time-datetime-T-Z-time-coming-Saturday">The Stand- Up Comedy show starts at <time datetime="2018-07-04T20:00:00Z">20:00</time> coming Saturday.</h3> <h3 id="The-preview-show-starts-in-time-datetime-PT-H-M-S-h-m-s-time">The preview show starts in <time datetime="PT3H0M3S">5h 1m 0s</time>.</h3>
In the below Output, the time tag instructs the browser about the text used between the attribute is a time reference ( 5 h 1m 0s) but doesn’t display the time attribute.
Output:
Example #3 – Using Css.
Code:
<article> <h1 id="Title-of-the-document">Title of the document</h1> <p>Introduction to the Article</p> </article> <footer> <p>This content is published on <time>2016-1-20</time>.</p> <p>Our shop opens at <time>08:00</time>.</p> </footer>
Output:
Example #4 – Using pubdate attribute.
Code:
<article> <h1 id="A-good-Article">A good Article</h1> <p>Introduction on a given Article.</p> <footer> <p>Content published on <time datetime="2019-02-04" pubdate>February the 4th, 2019</time> </p></footer> </article>
Output:
Conclusion
Therefore, we learned how to work with the
以上是HTML 时间标签的详细内容。更多信息请关注PHP中文网其他相关文章!

toinsertanimageIntoanhtmlpage,usethetagwithsrcandaltattributes.1)usealttextforAcccessibilityandseo.2)instementRcsetForresponSiveImages.3)applylazyloadingWithLoadingWithLoading =“ lazy” tooptimizeperformance.4)tooptimizeperformance.4)

HTML的核心目的在于让浏览器理解并展示网页内容。1.HTML通过标签定义网页结构和内容,如、到、等。2.HTML5增强了多媒体支持,引入了和标签。3.HTML提供了表单元素,支持用户交互。4.优化HTML代码可提升网页性能,如减少HTTP请求和压缩HTML。

htmltagsareessentialforwebdevelopmentastheyandendenhancewebpages.1)heSdefinElayout,语义和互动性。2)SemantictagsiCtagSimproveCacsibilitieAndseo.3)pose poseriblesibilityAndseoandseo.3)poser

一致的HTML编码风格很重要,因为它提高了代码的可读性、可维护性和效率。1)使用小写标签和属性,2)保持一致的缩进,3)选择并坚持使用单引号或双引号,4)避免在项目中混合使用不同风格,5)利用自动化工具如Prettier或ESLint来确保风格的一致性。

在Bootstrap4中实现多项目轮播的解决方案在Bootstrap4中实现多项目轮播并不是一件简单的事情。虽然Bootstrap...

如何实现鼠标滚动事件穿透效果?在我们浏览网页时,经常会遇到一些特别的交互设计。比如在deepseek官网上,�...

无法直接通过CSS修改HTML视频的默认播放控件样式。1.使用JavaScript创建自定义控件。2.通过CSS美化这些控件。3.考虑兼容性、用户体验和性能,使用库如Video.js或Plyr可简化过程。

在手机上使用原生select的潜在问题在开发移动端应用时,我们常常会遇到选择框的需求。通常情况下,开发者倾...


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

SublimeText3 Linux新版
SublimeText3 Linux最新版

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

SublimeText3 Mac版
神级代码编辑软件(SublimeText3)

Dreamweaver Mac版
视觉化网页开发工具