Sunday, June 7, 2015

The time element

INTRODUCTION

The <time> element is useful for marking a time or a duration in a document.

It provides both a human readable part (the part between <time> and </time>) and a machine readable part contained within a datetime attribute. Dates are expressed as YYYY-MM-DD.
This machine readable part adds semantics that can be used by search engines for indexing, by browsers or by browser extensions, or by JavaScript code. Useful scenarios include generating alerts for birthdays, automatically adding dates or events that contain <time> elements in a calendar, etc.

THE DATETIME ATTRIBUTE
The datetime attribute can be used for indicating a date/time or a duration.

DURATION VALUES

Duration values use the prefix “P” for “period” as in <time datetime="P4D"> (period = four days).

Using a “T” after the “P” marker allows you to indicate a more accurate duration time: <time datetime="PT4H 6M 12.55S"> is a duration of 4 hours, 6 minutes and 12.55 seconds.

No comments:

Post a Comment