html – 如何使用“UserComments”模式项?

前端之家收集整理的这篇文章主要介绍了html – 如何使用“UserComments”模式项?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
假设我有这样的标记
  1. <ul id="comments">
  2.  
  3. <li class="comment">
  4. <div class="author">on Friday 3th,Jenny said:</div>
  5. <div class="content"><p>bla bla</p></div>
  6. </li>
  7.  
  8. <li class="comment">
  9. <div class="author">on Friday 3th,Jenny said:</div>
  10. <div class="content"><p>bla bla</p></div>
  11.  
  12. <ul class="level-2">
  13. <li class="comment">
  14. <div class="author">on Friday 3th,Mary said:</div>
  15. <div class="content">stfu jenny</div>
  16. </li>
  17. </ul>
  18. </li>
  19. ...

如何在此标记上使用“UserComments”项目?
http://schema.org/UserComments

我在哪里添加itemscope itemtype =“http://schema.org/UserComments”?一旦列在容器上,或者在每个列表项上多次?

解决方法

根据 HTML5 Microdata类型的项目规格,您可以将其添加到您的评论部分的容器中,例如
  1. <section itemscope itemtype="http://example.org/animals#cat">
  2. <h1 itemprop="name">Hedral</h1>
  3. <p itemprop="desc">Hedral is a male american domestic
  4. shorthair,with a fluffy black fur with white paws and belly.</p>
  5. <img itemprop="img" src="hedral.jpeg" alt="" title="Hedral,age 18 months">
  6. </section>

因此,您的评论部分的项目范围将如此格式(考虑到项目属性):

  1. <ul id="comments" itemscope itemtype="http://schema.org/UserComments">
  2.  
  3. <li class="comment">
  4. <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>,Jenny said:</div>
  5. <div itemprop="commentText" class="content"><p>bla bla</p></div>
  6. </li>
  7.  
  8. <li class="comment">
  9. <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>,Jenny said:</div>
  10. <div itemprop="commentText" class="content"><p>bla bla</p></div>
  11.  
  12. <ul class="level-2">
  13. <li class="comment">
  14. <div itemprop="name" class="author"><span itemprop="commentTime">on Friday 3th</span>,Mary said:</div>
  15. <div itemprop="commentText" class="content">stfu jenny</div>
  16. </li>
  17. </ul>
  18. </li>
  19. ...

猜你在找的HTML相关文章