<time> Tag Syntax
<body> ... ... phrasing content expected ...<time datetime="yyyy-mm-ddThr:mi:ss.fracTZ">... phrasing content ... ... phrasing content ...</time>... ... </body>
Rules for coding the HTML time
element
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Code the time element where phrasing content is expected.
- Begin the time element with a starting <time> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Include a
datetime
attribute with the date and/or time inyyyy-mm-ddThr:mi:ss.fracTZ
,yyyy-mm-dd
orhr:mi:ss.fracTZ
format. - If the time element is the publication date of the document or of an article element that contains it, include a
pubdate="pubdate"
attribute to indicate that. - Include any other attributes of the <time> tag as appropriate.
- Inside the time element, between the starting
<time>
tag and the ending</time>
tag, code the inner HTML phrasing content with the text version of the time. - End the time element with a matching
</time>
closing tag.
Content Model
Content of the time element
The content of the time element can include HTML comments, text content and only those HTML tags that can be used in phrasing content. It should be the default display format of the date and/or time in the datetime
attribute.