Is <time> used?
Hi!
Just wandering if
<time>
is used at all?
So many websites have some sort of time data, but I've never seen the time tag used on them. Is there a reason for this?15 Replies
Never used it myself. What is the context? Semantics?
Seems like that's the main use case ...
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time
Perhaps in a form or some time picker.
You should use it if it's appropriate
I remember Kevin making a video about tags that we shouldn't really use, for all sorts of reasons. The time tag was not one of them, but just very curios why it isn't more used since time data is everywhere.
Yes, it seems like a very easy thing to just do.
People are lazy
If I need to offer it to google, I will use schema anyway and only add the CMS-generated date to a span or somthing. I do not car about accessibility rules either so this is a low priority. Perhaps I will have a look over time sometime.
Am I right to remember that somewhere in Kevins universe there's a video of tags that we don't use that should be used?
I honestly don't remember. Best bet is to look at mdn and check the usage notes. Just don't use semantic elements unless you're sure you're using them right, bad use is worse than just using divs and spans
Indeed. But e.g. when displaying multiple events in a program, the starting time for each event would be a logical place for the time tag, right?
Yup, think so
Just make sure to follow the usage notes
Thanx!
I'd use
<time>
for anything from specific times to when blog posts are put up and other stuff. If it's a date and/or time, no reason not to use it 🤷. I did talk about <time>
in a video, but I don't remember which one it was... it might have been one of my "obscure HTML elements" videos, I did 2 or 3 of those.
I'd also say, if you want to see if you're doing it 'correctly', looking at large, well known websites probably isn't the way to go, most of them are terrible, lol.
Look at ones that take markup seriously, like https://www.a11yproject.com/ - if you go to their posts, you'll see they use it for them. Smashing Magazine does too, for two quick examples if you want to see it used in the real world 🙂 - I could probably find more if you're curiousIt just seems like an easy semantic win, really ...
I'm guessing my take away is to look for specific tags if what I'm adding is something specific from the real world. It just fell into my head that time is so specific that maybe there is a tag for it.
And, I will spare you any time spent finding more examples. The fact is, from now on I will use it. Anything time related lives in a time tag. Easy-peasy!
... by the way. Here's the video.
https://youtu.be/JuLBQXERz8Y?feature=shared
Kevin Powell
YouTube
Obscure HTML elements that almost no one uses (but should!)
A look at some lesser known HTML elements.
🔗 Links
✅ The codepen: https://codepen.io/kevinpowell/pen/ZEaeENx
✅ MDN on mark: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/mark
✅ MDN on time: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/time
✅ MDN on output: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/ou...