Horje
How to display the time in HTML ?

The <time> Tag is used to display the human-readable date/time. It can also be used to encode dates and times in a machine-readable form. The main advantage for users is that they can offer to add birthday reminders or scheduled events to their calendars and search engines can produce smarter search results.

  • <time> is used to represent specific dates and times.
  • Utilize the datetime attribute for a machine-readable format.
  • Include human-readable content within the `<time>` tags.
  • Adds semantic meaning to time-related content.
  • Improves accessibility with both machine-readable and human-readable representations.

Syntax

<time attribute> Time... </time>

Example:

HTML

<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content=
          "width=device-width, initial-scale=1.0">
    <title>Time Element</title>
</head>
 
<body>
    <p>Published on
      <time datetime="2024-01-31">January 31, 2024</time>
      </p>
</body>
 
</html>

Output:

Screenshot-2024-01-24-170136




Reffered: https://www.geeksforgeeks.org


Web Technologies

Related
How to create a text area in HTML ? How to create a text area in HTML ?
How to implement Geolocation in HTML5 ? How to implement Geolocation in HTML5 ?
Create a Tooltip Button Animation using HTML and CSS Create a Tooltip Button Animation using HTML and CSS
Commonly used tools for testing in React Commonly used tools for testing in React
Purpose of the useContext hook Purpose of the useContext hook

Type:
Geek
Category:
Coding
Sub Category:
Tutorial
Uploaded by:
Admin
Views:
13