What’s the point of using the HTML5

前端 未结 4 1102
陌清茗
陌清茗 2020-12-23 18:38

I have been going through some tutorials on the tag, but I honestly don\'t see why we are using it.

For example:

Published          


        
相关标签:
4条回答
  • 2020-12-23 19:18

    It's in a machine-readable format, so any script or search engine reading your content can understand the date/time of publication. That way you can format it in a nice way for readers without affecting machine readability. It's covered under microformats which are a good thing.

    E.g. <time pubdate datetime="2011-07-03">3 days ago</time> looks nice for humans and computers.

    0 讨论(0)
  • 2020-12-23 19:29

    The time element also has an associated DOM API that can be used. See http://my.opera.com/ODIN/blog/2011/05/31/dom-scripting-and-the-time-element and http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-time-element

    0 讨论(0)
  • 2020-12-23 19:36

    HTML5 time element

    When in doubt look at the spec!

    The time element represents its contents, along with a machine-readable form of those contents in the datetime attribute. The kind of content is limited to various kinds of dates, times, time-zone offsets, and durations, as described below.

    From the HTML5.2 spec on the W3C site: https://www.w3.org/TR/html52/textlevel-semantics.html#the-time-element

    Have a look at the site for more info. :)

    0 讨论(0)
  • 2020-12-23 19:40

    The point of this tag, as with a number of the new "semantic" HTML5 tags, is to make it easier for programs to index your data.

    A script can go through and easily find out what the published date is for your blog articles if it sees a <time> tag, without having to parse any of a number of ways this could be represented (for consumption by a human being), which would be a much more complex and error-prone task.

    0 讨论(0)
提交回复
热议问题