Thanks to visit codestin.com
Credit goes to www.cssportal.com

CSS Portal

CSS <time> Data Type

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!

Description

The <time> CSS data type represents temporal values, typically dates or times, and is often used in conjunction with the HTML time element. It allows authors to provide semantic meaning for time-based content, which can be leveraged in styling, animations, and user interface enhancements. Unlike generic string values, <time> is specifically recognized as a temporal value, enabling more precise formatting and potential integration with scripts that manipulate date and time.

One of the key benefits of the <time> data type is that it can interact with CSS functions and properties that accept temporal values, such as animation-delay or transition-duration. This allows developers to create animations or transitions that are synchronized with specific time intervals. For example, you might define a transition that starts exactly 5 seconds after the page loads using a <time> value.

Additionally, the <time> data type is useful when combined with custom properties for dynamic styling. For instance, you can store a date or time in a CSS variable and reference it in animations or pseudo-elements. This enables more flexible and readable CSS code, particularly when designing timelines, countdowns, or time-based visual effects.

Here are some examples:

<time datetime="2026-01-03T10:00">January 3, 2026</time>
/* Example using <time> for animation-delay */
time {
  animation: fadeIn 2s ease-in-out;
  animation-delay: 5s; /* could be derived from a <time> value */
  display: inline-block;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
/* Using a CSS variable to store a time value */
:root {
  --event-time: 10s; /* represents a time duration */
}

time::after {
  content: "⏱";
  animation: blink var(--event-time) infinite;
}

@keyframes blink {
  0%, 50%, 100% { opacity: 1; }
  25%, 75% { opacity: 0; }
}

In essence, <time> provides a semantic and functional approach to representing temporal values in CSS, bridging the gap between content meaning and visual presentation. By leveraging it with properties like animation-delay or transition-duration, developers can create more intuitive, accessible, and time-aware designs.

Syntax

property: <time>; 

Values

  • sRepresents a time in seconds.
  • msRepresents a time in milliseconds

Example

  <section class="event">
<h2>Upcoming events</h2>

<p>
Next meeting:
<time class="meeting-time" datetime="2026-01-15T14:00:00Z">Jan 15, 2026 - 2:00 PM UTC</time>
</p>

<ul class="schedule">
<li>
<time class="date" datetime="2026-01-02">Jan 2, 2026</time>
<span class="note">Project kickoff</span>
</li>
<li>
<time class="date" datetime="2027-03-10">Mar 10, 2027</time>
<span class="note">Quarterly review</span>
</li>
</ul>
</section>
time {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
}

/* Base appearance for any 

Browser Support

The following information will show you the current browser support for the CSS time data type. Hover over a browser icon to see the version that first introduced support for this CSS data type.

This data type is supported by all modern browsers.
Desktop
Chrome
Edge
Firefox
Opera
Safari
Tablets & Mobile
Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-

Last updated by CSSPortal on: 3rd January 2026

If this site has been useful, we’d love your support! Consider buying us a coffee to keep things going strong!