简体   繁体   中英

In HTML5 should I use article or section tags to make tabs?

I want to create a set of content tabs for a design I'm building in HTML5. I'm wondering if I should use a set of <article> or <section> tags to contain the content?

<section> seems ideal to me. Its definition applies quite neatly to something like content tabs:

The section element represents a generic section of a document or application. A section, in this context, is a thematic grouping of content, typically with a heading.

Examples of sections would be chapters, the various tabbed pages in a tabbed dialog box, or the numbered sections of a thesis. A Web site's home page could be split into sections for an introduction, news items, and contact information.

Take note of what it says about <article> on that same page though:

Authors are encouraged to use the article element instead of the section element when it would make sense to syndicate the contents of the element.

So if the content of your tabs is self-contained and makes sense when read in isolation (and could be used that way), use <article> , if it doesn't use <section> .

It is my understanding that <section> elements are supposed to go inside <article> elements, so you shouldn't use sections for tabs unless you wrap all of the tabs inside of an article. So the short answer is you should use both or neither.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM