views:

35

answers:

4

AFAIK, there is no dedicated element--like <caption> for tables, <figcaption> for figures, etc.--to mark the header of a list. What markup should I use?

In HTML 3.0, there was an element <LH> but it is deprecated now.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eget enim nec metus feugiat porta. Suspendisse convallis dictum tincidunt. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi vitae erat in nisl suscipit rutrum.

Fruits I love:

  • Ananas

  • Raspberry

  • Banana

In in mauris vel diam eleifend adipiscing. Proin id neque quam, eu mattis ipsum. Nulla facilisi. Sed id sapien eget mi cursus placerat vel sed justo. Integer vel pellentesque magna. Donec quis nisi lacus, accumsan rhoncus leo. Quisque tempor metus vitae nisl eleifend aliquet. Maecenas adipiscing purus magna.

+1  A: 

I'd use a regular header, preferably in the level below your previously used one.

Mickel
The problem here is that the whole content right after the list until the next heading will belong to the list's heading which is semantically incorrect.
Török Gábor
I feel you, but I'm pretty sure your users won't notice :)
Mickel
+2  A: 

It looks like you want a HTML5 answer. If all your lists have header I would use a <dl> (now meaning description list) with a single <dt> header and the list items as <dd>'s:

<dl>
    <dt>Fruits I love:</dt>
    <dd>Ananas</dd>
    <dd>Strawberry</dd>
</dl>

If you mix a lot of lists with/without headers I would stick with <ul>/<ol> and use normal <hX>'s. Wrap the <hX> and the list in a <div> to preserve the semantics:

<div class="list">
    <h2>Fruits I love:</h2>
    <ul>
        <li>Ananas</li>
        <li>Strawberry</li>
    </ul>
</div>
schot
Definition lists are great for making markup semantic but aren't so great for making markup accessible. As such, I've had to give up a lot of my favorite uses of DLs.
DA
Placing the list in a `<figure>` is not a good idea as `<figure>` is an element "that can be moved away from the main flow of the document without affecting the document’s meaning." In my case list is strictly part of the main flow.
Török Gábor
@Török Is this comment meant for msger?
schot
@schot: nope, for you. You suggested `<figcaption>` which can be used inside a `<figure>`.
Török Gábor
Then you misunderstood me: I meant that since *you* mention `<figcaption>` in your question, you are looking for a HTML5 answer. I'll remove it to avoid confusion.
schot
@schot: I see now.
Török Gábor
+1  A: 
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eget enim nec metus feugiat porta. Suspendisse convallis dictum tincidunt. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi vitae erat in nisl suscipit rutrum.</p>

<p>Fruits I love:</p>
<ul>
  <li>Ananas</li>
  <li>Raspberry</li>
  <li>Banana</li>
</ul>

<p>In in mauris vel diam eleifend adipiscing. Proin id neque quam, eu mattis ipsum. Nulla facilisi. Sed id sapien eget mi cursus placerat vel sed justo. Integer vel pellentesque magna. Donec quis nisi lacus, accumsan rhoncus leo. Quisque tempor metus vitae nisl eleifend aliquet. Maecenas adipiscing purus magna.</p>

There's no reason to use anything else than a paragraph in this case. figcaption would be appropriate in another circumstance:

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eget enim nec metus feugiat porta. Suspendisse convallis dictum tincidunt. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi vitae erat in nisl suscipit rutrum.</p>

<p>I love <a href=#fruits>some fruits</a>!</p>

<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eget enim nec metus feugiat porta. Suspendisse convallis dictum tincidunt. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Morbi vitae erat in nisl suscipit rutrum.</p>

<p>In in mauris vel diam eleifend adipiscing. Proin id neque quam, eu mattis ipsum. Nulla facilisi. Sed id sapien eget mi cursus placerat vel sed justo. Integer vel pellentesque magna. Donec quis nisi lacus, accumsan rhoncus leo. Quisque tempor metus vitae nisl eleifend aliquet. Maecenas adipiscing purus magna.</p>

<figure id=fruits>
  <figcaption>List 1: Fruits I love</figcaption>
  <ul>
    <li>Ananas</li>
    <li>Raspberry</li>
    <li>Banana</li>
  </ul>
</figure>
Ms2ger
A: 

There are few things you can do:

  1. Use HTML5, as schot pointed out
  2. Use HTML3, as you noticed :)
  3. I'd use the headings, which are very good for navigation and marking general semantic structure of the page:

    <h3>Things I love</h3>

    <h4>The list</h4>
    <ul>
    <li>Ananas</li>
    <li>Raspberry</li>
    <li>Banana</li>
    </ul>

    <h4>Elaborated description</h4>

    <p>Lorem ipsum…</p>

(Sorry for this formatting)

If you use Firefox, I'd recommend HeadingsMap to clearly see the page structure:

HeadingsMap :: Add-ons for Firefox

takeshin