html - HTML5 中卡片/卡片容器的元素?

标签 html semantic-markup teaser

article 元素的规范说:

The article element represents a component of a page that consists of a self-contained composition in a document, page, application, or site and that is intended to be independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.



因此,如果我正在构建一个网站,在该网站的主页中,我有可点击的卡片并将您引导至文章页面,那么在语义上,这张卡片是 section 还是 article 元素会更好?

最佳答案

article 元素用于发布预告片可能是合适的。这取决于您显示的内容。例如:

  • :如果您显示标题、描述、图像、作者姓名和出版日期,则绝对应该使用 article 元素。
  • :如果只显示标题,则不需要 article 元素,因为每个预告片都将成为文档大纲中的一个条目(因为 article 是一个分节内容元素),但没有太多意义如果它不包含任何附加内容,则为大纲条目。
  • 也许 :介于两者之间。标题和日期?可能不会。标题和描述?可能是。

  • 如果您决定使用 article(并且只有那时!),您可以使用 bookmark link type 作为指向完整文章页面的链接。这可能暗示您的 article 不是“完整的东西”。

    如果您决定不使用 article ,请不要使用 section 。如果在 articlesection 之间进行选择,则 article 是预告片的正确选择。但是如果 article 不合适,你不应该使用另一个分节内容元素,而是使用类似 p 和/或 ul 的东西(并且没有标题元素)。

    关于html - HTML5 中卡片/卡片容器的元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43953026/

    相关文章:

    MySQL/PHP - 根据日期更改状态

    html - CSS全屏背景rgba叠加

    html - 如何向 <=IE6 显示某些内容,而向其他浏览器显示不同的内容?

    html - CSS 定位 - 如何解决加载问题

    html - 有必要在h1之后用h2吗

    java - 创建线程来运行算法播放器

    php - Drupal 7 使用 field_view_value() 获取预告片

    html - 集中分离 h 标签和 p 标签

    html - css 网格——我还需要使用列表吗?

    html - 如何语义标记类别标题