Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML5, <section> inside unordered list

Can I use <section> tag inside unordered list?

I know, that <section> represent a generic section of document. Usually we find heading inside.

So... I have list of products. Usually about 20 per page. Each element have:

  • heading,

  • short description (max 255 chars),

  • thumbnail, some details, button.

So each list item is something like section, "is a thematic grouping of content, typically with a heading".

Of course I don't use, <section> to styling purpose.

I think, <section> also could be here a wrapper for a list, and each element of list <article>.

What is your opinion?

like image 561
Mr Sooul Avatar asked Aug 24 '11 09:08

Mr Sooul


People also ask

Can an unordered list contain a heading element?

It depends upon context but usually the heading appears outside of the UL itself as a 'heading' for the list not an item of the list. <li> is an inline element, where headings are block elements. Placing block elements inside inline elements isn't something to do casually.

Can you have a section within a section HTML?

Sectioning elements can be nested inside one another as many times as is needed based on the content. The header and footer in a sectioning element can also contain sectioning elements.

Should I use section or div?

When an element is needed only for styling purposes or as a convenience for scripting, authors are encouraged to use the <div> element instead. A general rule is that the <section> element is appropriate only if the element's contents would be listed explicitly in the document's outline.

How do you add bullets in ul li?

You create an unordered list using the ul tag. Then, you use the li tag to list each and every one of the items you want your list to include. tag.


1 Answers

Using a <section> tag inside an <li> tag validates (you can try this using the “Text Field” option on http://html5.validator.nu/), and the spec doesn’t seem to suggest you shouldn’t use it in this way (see http://dev.w3.org/html5/spec-author-view/the-section-element.html#the-section-element), so that seems fine to me.

The <article> tag is meant for “self-contained compositions”. I’ve never been entirely clear what that means outside of several blog posts being listed on a single page, but I think product summaries sound like a decent fit for that too. So your second idea of a <section> containing the entire list, and an <article> for each product, probably sounds best.

like image 200
Paul D. Waite Avatar answered Nov 07 '22 14:11

Paul D. Waite