Proper datetime attribute for <time>

走远了吗. 提交于 2019-11-28 10:47:07

问题


While Schema.org writes

Here is an example: <time itemprop="openingHours" datetime="Tu,Th 16:00-20:00">Tuesdays and Thursdays 4-8pm</time>.

on the HTML5 validator I get this error:

Bad value Mo, Tu, We, Th, Fr 09:00-16:00 for attribute datetime on element time: The literal did not satisfy the time-datetime format.

…" datetime="Mo, Tu, We, Th, Fr 09:00-16:00">every work day 9am to 16pm </time></li>

I really want to communicate the opening hours (and days) in Microdata, but it seems this is in conflict with HTML5.

Is there a format that is good for both or I should keep it for the bots and care not about valid HTML in this case?


回答1:


I would suggest to keep what you have and not worry about the HTML validator which is only a guide at any rate.




回答2:


Don’t use the time element.

It’s an error with Schema.org’s documentation. I reported this issue in the Schema.org tracker and it will likely be fixed in the next release.

Possible alternatives:

  • data element:

    <data itemprop="openingHours" value="Tu,Th 16:00-20:00">Tuesdays and Thursdays 4-8pm</data>
    
  • meta element (which can be used in the body):

    <meta itemprop="openingHours" content="Tu,Th 16:00-20:00"> Tuesdays and Thursdays 4-8pm
    


来源:https://stackoverflow.com/questions/28088266/proper-datetime-attribute-for-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!