Links inside HTML5 footer element (nav and aside?)

对着背影说爱祢 提交于 2019-12-05 06:36:00

I would suggest simply using a <footer> with links in it.

If you want to wrap the links in a <nav>, that’s acceptable, but I would advise against it. The <nav> element is intended to mark up “major” navigation blocks, and the fact that you’re putting the links in a footer suggests that they are not a major navigation block. (In a sense, <footer> and <nav> are almost contradictory.) The spec even talks specifically about this scenario:

Not all groups of links on a page need to be in a nav element — the element is primarily intended for sections that consist of major navigation blocks. In particular, it is common for footers to have a short list of links to various pages of a site, such as the terms of service, the home page, and a copyright page. The footer element alone is sufficient for such cases; while a nav element can be used in such cases, it is usually unnecessary.

As for <aside>, I would say it’s overkill if you’re only going to put a few links in it, especially since it sounds like, though external, they belong together with the other links. If it helps with styling, and the external links feel like kind of a self-contained unit, then sure—otherwise, don’t bother. I would say the <footer> element itself already carries enough aside-ish semantics.

Do you already have the links within the footer that you intend to wrap in a nav, already in a nav, for example in the header? (as sites often duplicate the header links in the footer).

If so, then I'd suggest not wrapping the links in the footer within a nav at all, as they're for main navigation only, and if you're duplicating the links, then only one set (e.g. the ones in the header) should be in a nav.

If this isn't the case, and none of the footer links are duplicates and are important, then it's fine to wrap some in a nav and others not, but retaining them in the footer.

I wrote an article a while back, HTML5 - To nav or not to nav, a while back which might help.

The HTML5 spec actually specifically calls out the use-case of links to various site pages in the footer, as says you don’t need to use <nav> for those:

<aside> seems fine for the external links in the footer (as per http://dev.w3.org/html5/spec-author-view/the-nav-element.html#the-nav-element), although I don’t know how much meaning it really adds. I don’t think you need to take those links out of the footer.

It’s not worth over-thinking your HTML tag choices. Who’s actually going to be confused about your markup as it stands?

If you don't need to group the links to external pages for some reason (i.e. styling), I think your approach is OK.

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