liveBook · Manning

Time element

As explained in Web Design Playground, Second Edition

The HTML time element marks text as representing a date, a time, or both, optionally associating it with a machine-readable value.

The HTML <time> element marks text as a date, a time, or both. The visible text helps people, while the optional datetime value gives browsers and other software a machine-readable version. section 16.1

A readable timestamp with a precise value

This web page was last modified on <time datetime="2023-08-23T09:25:00-05:00">August 23rd, 2023 at 9:25AM</time>. The browser does not automatically restyle the date; the element mainly adds meaning and useful data. section 16.1

Here's the syntax to use for the <code>time</code> element:<br> <code>&lt;time datetime="<var>machine-value</var>"&gt;<var>human  text</var>&lt;/time&gt;.</code>

Use the pattern <time datetime="machine-value">human text</time>, replacing each placeholder with the appropriate machine-friendly and human-friendly values. section 16.1

How Web Design Playground, Second Edition covers it

How deep it goes
Explains visible text, datetime values, syntax, and browser behavior without detailing date-format rules.
Examples
Uses a page last-modified timestamp with human text and an ISO-like datetime value.
What it assumes
Assumes basic HTML tags and attributes while introducing semantic date/time markup from its general syntax.
What you can do after
Build it from scratch by marking readable dates or times with an optional machine-friendly datetime value.
How it connects
Connects semantic HTML, datetime attributes, machine-readable values, and page creation or modification dates.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.