Can I use <nav> tag for list of article tags?

只愿长相守 提交于 2019-12-20 04:52:03

问题


After the article I have list of tags related to article. Is it semantically correct to wrap list of those tags in <nav> html tag? If no, what would be the proper one?

<nav class="tags">
    Tags:
    <ul>
        <li><a href="#">Tag1</a></li>
        <li><a href="#">Tag2</a></li>
        <li><a href="#">Tag3</a></li>
    </ul>
</nav>

MDN states:

  1. Not all links of a document must be in a <nav> element, which is intended only for major block of navigation links; typically the <footer> element often has a list of links that don't need to be in a <nav> element.
  2. User agents, such as screen readers targeting disabled users, can use this element to determine whether to omit the initial rendering of this content.

回答1:


The <nav> tag defines a set of navigation links.

Notice that NOT all links of a document should be inside a <nav> element. The <nav> element is intended only for major block of navigation links.

Browsers, such as screen readers for disabled users, can use this element to determine whether to omit the initial rendering of this content.




回答2:


The tags are part of the article’s metadata (just like the author name, the publication date, etc.), so they should be in a footer element, and this footer should be inside the article element:

<article>
  <footer><!-- tags --></footer>
</article>

(Some might use header instead of footer, but its default role banner is not really appropriate, and it can’t have the contentinfo role, which would be appropriate.)

For such a simple list of tags, another sectioning element isn’t really needed.

Related: my answer about semantic markup for tags.



来源:https://stackoverflow.com/questions/31434988/can-i-use-nav-tag-for-list-of-article-tags

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