How to display the time in HTML ?
Last Updated :
30 Jan, 2024
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:
Share your thoughts in the comments
Please Login to comment...