【问题标题】:Proper use of HTML5 semantic tags正确使用 HTML5 语义标签
【发布时间】:2017-05-24 07:39:19
【问题描述】:

我正在努力将语义标签适当地应用于显示古物目录的网站。

第一个问题是关于主要结构的:

body
  header
    h1
    h2
    nav
      a
      ...
      a
  main
    div        // Search field and a button to open a spacious filter pane
    article
    article
    article
    ...
    article
    div        // Pagination
  footer
    p

将两个带有搜索和过滤选项的div以及分页放入main标签是否正确?还是应该在main前后的body标签中独立?

第二个问题是关于上述结构中的文章:

    article
      figure
        img     // depicts the antiquity
      figcaption
        header
          h3    // title of the antiquity
          p     // detailed description of the antiquity
        section
          p     // first owner of the antiquity
          p     // second owner of the antiquity
          ...
          p     // last and therfore current owner of the antiquity
        section
          p     // first literature record on this antiquity
          p     // second literature record on this antiquity
          ...
          p     // last literature record on this antiquity

通过查看其他问题和答案,我很确定可以在文章中以这种方式使用该部分是正确的。我完全不安全的是将完整的古代条目文本放入 figcaption。

【问题讨论】:

  • 您的两个问题似乎没有足够的相关性,因此将它们放在同一个帖子中是有意义的。

标签: html semantic-markup


【解决方案1】:

使用 div 进行搜索非常好。

您可以使用导航元素进行分页: https://developer.mozilla.org/en/docs/Web/HTML/Element/nav

至于文章元素的结构。 fig 标题应该是 figure 的第一个或最后一个子项,有关详细信息,请参见此处: https://developer.mozilla.org/en/docs/Web/HTML/Element/figure
https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption

所以我建议让你的文章看起来更像:

article
  figure
    img     // depicts the antiquity
    figcaption  //text about the image
  header
    h1    // title of the antiquity
    p     // detailed description of the antiquity
  section
    p     // first owner of the antiquity
    p     // second owner of the antiquity
    ...
    p     // last and therefore current owner of the antiquity
  section
    p     // first literature record on this antiquity
    p     // second literature record on this antiquity
    ...
    p     // last literature record on this antiquity

虽然最好使用正确的标记,但我不相信你会因为弄错而受到惩罚。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-04-03
    • 2011-07-07
    • 1970-01-01
    • 2014-06-01
    • 2011-11-03
    • 1970-01-01
    相关资源
    最近更新 更多