Vanilla Breeze v0.7.4

Vanilla Breeze v0.7.4 released

0.7.4 gives the Ambient pack weather. A page names one feed URL on its own site, and the pack sets data-weather from it, uses its sunrise and sunset for dawn and dusk, and never shows a stale observation. Helpers for producing the feed from Open-Meteo are included. Ambient p…

Read the release notes

time

The time element represents a specific period in time, providing a machine-readable datetime value while displaying a human-readable format to users.

Description

The <time> element represents a specific moment or range of time. It encodes dates and times in a machine-readable format via the datetime attribute while displaying human-friendly text. Search engines, browser features and scripts (including VB's formatters below) read datetime; people, including screen reader users, get the visible text.

When to Use

  • Publication dates — Blog posts, articles, news
  • Event times — Meetings, appointments, concerts
  • Deadlines — Due dates, expiration dates
  • Historical dates — Birthdays, anniversaries, milestones
  • Durations — Length of videos, podcasts, events

When Not to Use

  • For vague time references ("Last week", "Soon") with no specific datetime
  • For non-Gregorian dates that can't be represented in ISO 8601
  • For machine-readable non-temporal values — use <data>

Basic Usage

Standard time element with tabular numeric font for consistent digit widths.

Relative Time

The relative class is styling only: muted, smaller text. It does not change the text. To keep "3 days ago" text current, pair it with one of VB's two relative-time scripts. Write an absolute date as the element's text, so readers without JavaScript still get a correct date.

data-relative

time[data-relative] is the lightweight past-only formatter used by <activity-feed>, <comment-thread> and <time-index>. It is part of the main bundle and needs no setup. It rewrites the text to "just now", "5 minutes ago", "3 days ago" and so on, and refreshes every 60 seconds. Future dates are left as written. Text is English unless the nearest [lang] is another language, in which case it uses Intl.RelativeTimeFormat.

Choosing a relative-time mechanism

Mechanism What it does Future dates Refresh Locale
time.relative Styling only (muted, small). Text is whatever you write. n/a None n/a
time[data-relative] Rewrites text to "3 days ago" Ignored (text kept) Every 60s English; Intl for a non-English nearest [lang]
time[data-format-date="relative"] Rewrites text with Intl.RelativeTimeFormat; original text moves to title "in 3 days" Adaptive: 60s, 5 min, then hourly data-locale, nearest [lang], <html lang>, browser

Use data-format-date="relative" for new content: it handles future dates and every locale. data-relative exists for the components that render it.

Datetime Variant

Monospace font for technical datetime displays, such as log entries or API timestamps.

Badge Variant

A bordered, rounded-corner chip in the monospace face for dates that need to stand out, such as event dates, release versions, or deadlines. Add the boolean data-badge attribute to any <time> element. It uses the raised surface, the default text colour and --color-border, so it keeps the page's text contrast in light and dark mode, and its border stays visible in forced-colours mode.

data-badge only styles <time>. For status labels, counts or decorative ribbon, flag and stamp shapes use <layout-badge>; wrap it around the <time> if a date needs a coloured or shaped badge.

Formats and Patterns

Dates, times, combined formats, and ISO 8601 durations.

Auto-Formatting (data-format-date)

VB provides locale-aware date formatting via the data-format-date attribute. Like <data>'s data-format-number, the visible text serves as a no-JS fallback and is replaced with formatted output on init. The original text moves to the element's title, so it stays available on hover.

Attribute ValueOutput (en-US)
data-format-date (empty)Feb 9, 2026 (medium)
data-format-date="short"2/9/26
data-format-date="long"February 9, 2026
data-format-date="full"Monday, February 9, 2026
data-format-date="relative""2 days ago", "in 3 hours"

Date-only values (2026, 2026-02, 2026-02-09) are formatted in UTC, so the day never shifts with the reader's time zone, and keep their precision: a year shows only the year, a month shows month and year. Add data-format-time for time display (short, medium, long, full) on values that have a time. The locale comes from data-locale, then the nearest [lang] ancestor, then <html lang>. See the i18n guide for locale resolution.

Contextual Usage

Time elements work naturally in article metadata, event listings, and other contextual patterns.

datetime Attribute Formats

The datetime attribute uses ISO 8601 format:

Format Example Represents
YYYY 2026 Year
YYYY-MM 2026-01 Month
YYYY-MM-DD 2026-01-15 Date
HH:MM 14:30 Time
YYYY-MM-DDTHH:MM 2026-01-15T14:30 Date and time
YYYY-MM-DDTHH:MM:SS 2026-01-15T14:30:00 With seconds
...Z 2026-01-15T14:30:00Z UTC timezone
...+HH:MM 2026-01-15T14:30:00+05:30 With timezone offset
PTXHXMXS PT2H30M Duration

Variant Summary

Variant Selector Use Case
Default time Standard dates with tabular numerals
Relative time.relative Muted styling for relative displays (pair with data-relative or data-format-date="relative")
Datetime time.datetime Technical timestamps in monospace
Badge time[data-badge] Bordered chip emphasis for key dates

CSS Properties

Accessibility

  • Screen readers read the visible text content. Mainstream screen readers do not expose the datetime value, so the visible text must be unambiguous on its own: prefer "9 February 2026" over "2/9/26".
  • Timezone clarity — include timezone information when relevant to avoid ambiguity
  • Relative times — keep them current with data-relative or data-format-date="relative", and write the actual date as the fallback text
  • <data> — Machine-readable values that aren't dates (has data-format-number counterpart)
  • <del> / <ins> — Use datetime attribute for edit timestamps
  • <small> — Often paired with time for date caveats
  • data-format-date — Locale-aware absolute and relative formatting
  • <layout-badge> — Coloured status badges and decorative badge shapes
  • Internationalization — Locale resolution for date formatting
  • datetime — Machine-readable dates, times and durations
↑