首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正确使用HTML5语义标记

正确使用HTML5语义标记
EN

Stack Overflow用户
提问于 2017-05-24 07:39:19
回答 1查看 180关注 0票数 2

我很难在一个展示文物目录的网站上恰当地应用语义标签。

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

代码语言:javascript
复制
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之前和之后的主体标记中它们是独立的?

第二个问题是关于上述结构中的条款:

代码语言:javascript
复制
    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

通过查看其他问题和答案,我非常肯定,在文章中可以这样使用部分是正确的。我完全不放心的是,把完整的古代条目文本放入图形标题中。

EN

回答 1

Stack Overflow用户

发布于 2017-05-24 08:19:10

使用div进行搜索是非常好的。

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

关于项目元素的结构。图标题应该是图中的第一个或最后一个子元素,请参见这里的详细信息:https://developer.mozilla.org/en/docs/Web/HTML/Element/figure

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figcaption

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

代码语言:javascript
复制
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

虽然正确的标记是首选的,但我不相信你会因为弄错而受到惩罚。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44151961

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档