Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

article, section or div for list of products?

Tags:

html

I'm currently working on an ecommerce project and can't work out whether to use article, section or a div to wrap the product listing.

There are multiple sections following it for things such as promos and I don't want to use div since the following sections would have a greater meaning and undermine it, however it should have a greater meaning than the following sections.

Image of layout

I'm considering the article tag but I cannot find an example of it being used outside of a blog. I've noticed people deem it acceptable for single items (product pages), but what approach should be used for browsing product listings?

like image 367
4lun Avatar asked Mar 15 '12 11:03

4lun


People also ask

When should you use section div or article?

If the content within the element is not semantically related, then use a <div> . If the semantically related content is also able to be self-contained, then use an <article> . Otherwise, use a <section> .

When should we use Article tag?

The <article> tag specifies independent, self-contained content. An article should make sense on its own and it should be possible to distribute it independently from the rest of the site. Potential sources for the <article> element: Forum post.

What is the difference between section and article HTML?

The <section> tag defines a section in a document. The <article> tag specifies independent, self-contained content.


1 Answers

The section specification is very instructive:

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

Note: The section element is not a generic container element. When an element is needed for styling purposes or as a convenience for scripting, authors are encouraged to use the div element instead.

If a number of elements are thematically related and can be grouped together under a common title (e.g. "Shoes") then wrap the products in a section.

If the elements you are wrapping are not related, cannot be grouped under a common title and are just being wrapped for the purpose of styling then use a div.

For completeness, the article tag represents (from the same page):

a self-contained composition in a document, page, application, or site and that is, in principle, independently distributable or reusable, e.g. in syndication. This could be a forum post, a magazine or newspaper article, a blog entry, a user-submitted comment, an interactive widget or gadget, or any other independent item of content.

so your items for sale would each be an article within the section.

As a final side note, I wouldn't wrap the whole page in a <div role="main">: surely the header sits outside of the main content.

like image 80
Chris Avatar answered Oct 01 '22 17:10

Chris