HTML Academy
The sub and sup tags, which are used to indicate subscript and superscript
Text markup15/21
Back to the list of tasks
  • 1. Let’s start the diary
  • 2. The ul tag, which is used to indicate an unordered list
  • 3. The ol tag, which is used to provide an ordered list
  • 4. The start and reversed attributes
  • 5. Nested lists
  • 6. The dl, dt and dd tags for description lists
  • 7. The pre tag, which is used to designate preformatted text
  • 8. HTML entities
  • 9. The code tag for code snippets
  • 10. Combining pre and code tags
  • 11. The q tag for inline quotations
  • 12. The blockquote tag for block quotations
  • 13. The br tag, which is used to create a line break
  • 14. The sub and sup tags, which are used to indicate subscript and superscript
  • 15. The time tag, which is used to specify the date and time
  • 16. The em and i tags, which are used to attract the user’s attention
  • 17. The strong and b tags, which are used to strengthen or highlight text
  • 18. The del and ins tags, which are used to highlight changes
  • 19. The div and span tags, style containers
  • 20. Summary of “Text markup”
  • 21. Test: Marking up an article
The em and i tags, which are used to attract the user’s attention
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The time tag, which is used to specify the date and time

In the next blog post, Muffin wants to show exactly what time of day (or rather, night) it was written. A string with the time can be simply left in the text, but there is a better option. HTML has a special tag for marking up the date and time. This is the <time> tag.

The <time> tag lets you provide a date or time in two forms: one for people to read and one for machines.

The human-friendly time can be in any format: “Yesterday”, “Saturday”, “суббота”, “The Feast of Saint Muffin” are all legitimate. But machines don’t understand such ambiguous descriptions, so they require a strict format called the ISO 8601 format.

The date for the person is described inside the tag, and the machine-friendly date is described inside the datetimeattribute:

<time datetime="2016-11-18T09:54">09:54 AM</time>

<time datetime="2015-11-18">November 18, 2015</time>

<time datetime="2018-09-23">last Sunday</time>

<time datetime="2017-04-20">yesterday</time>

The browser displays the text inside the tag; it does not display the datetime value. People see a date or time in a form they can understand, while programs read the attribute to get the same information in a precise format. That gives both people and machines what they need.

We added some styles to make the <time> tags look prettier. You can explore the styles in the style.css tab.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>The website of a beginning coder</title> <link rel="stylesheet" href="style.css"> </head> <body> <header> <p>Blog</p> <nav> Return to home </nav> </header> <main> <article> <h1>Day Nine. Or, more precisely, night.</h1> 03:00 <p>Suddenly I woke up tonight because I had a nightmare: what if people suddenly no longer needed coders, and everything was done by robots?</p> <p>“What a beautiful idea”, I thought, and I rolled over and went to sleep.</p> </article> <aside> Your ad could go here </aside> </main> <footer> Website footer </footer> </body> </html>
CSS
body { padding: 0 30px; font-size: 14px; line-height: 22px; font-family: "Georgia", serif; color: #222222; } h1 { font-size: 20px; line-height: normal; } nav { color: #888888; } aside { margin: 20px 0; color: #c4c4c4; } time { color: #6a2cce; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Enclose the text 03:00 in <time>.
    2. Enclose the text tonight in <time>.
    3. Add datetime="2018-11-27T03:00" to the <time> element around 03:00.
    4. Add datetime="2018-11-27" to the <time> element around tonight.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2026

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.