سؤال

I am using time tag to define a time—seemed like the right approach ;-)

My problem however is the value I want to place within the time tag is NOW: the present. I get this validation error:

The text content of element time was not in the required format:
The literal did not satisfy the time-datetime format."

Looking at the spec, it doesn't seem possible to define 'NOW'. That's a nuisance. Any ideas on how to approach this?

هل كانت مفيدة؟

المحلول

You cannot. The time element in HTML5 is defined as markup for specific moments or periods or durations of time or for time offsets, not for all concepts related to time.

You can write e.g. <time datetime="2013-04-06T13:53">now</time>, thereby associating a fixed moment of time with the text content “now”. I don’t see how this could be useful, and the usefulness of the time element in general is questionable (it looks like markup for markup’s sake), but things like this are all you can do to “define ‘NOW’” with time.

نصائح أخرى

I'm using this markup for now:

<time datetime="2013">Present</time>

No more errors, and it's symatic. It's just a shame there is no accepted variable for NOW.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top