Forum Moderators: open
I have a list I would like to give a name. Let's say its a list of Operating systems.
I could go this way:
<p>Operating Systems</p>
<ul>
<li>OS 1</li>
<li>OS 2</li>
<li>OS 3</li>
</ul>
But that doesn't seem very proper.
I've scoured around the w3 website, and found them using dl, dt and dd tags, to get something like:
<dl>
<dt>Operating Systems</dt>
<dd>
<ul>
<li>OS 1</li>
<li>OS 2</li>
<li>OS 3</li>
</ul>
</dd>
</dl>
I'm wondering, is this the proper way of doing this? Is it really definition lists, terms and descriptions? Or am I just misinterpreting their examples.
Here's the w3 link to the page where I got the idea from: [w3.org...]
Thanks for any feedback.
Actually it makes sense. We usually think of one description per one term but it is very possible and reasonable to have multiple descriptions per term (i.e. a dictionary word may have one or many descriptions) and (albeit rare in practice) one description for many terms or even many to many (your w3c link does give examples of each).
Also as you note there is no inherent method of labeling/naming unordered/ordered lists themselves. So you add a <span> or enclose the list in a <p> or you enclose it in a <dl>. I like the <dl> for retaining the semantics of a list.
Comimg from the other direction - a 'traditional' <dl> might well be visually helped by the bullets of a <ul> within one <dd> rather than multiple <dd>s. A combination of personal preference and semantic considerations.
It also allows even further definition while retaining semantic value i.e. your OS <li>s could each sprout subsequent lists of versions, etc.
There is a lot of unused power in lists.
If it's a heading why not mark it up as such?
There is a difference between a heading and a name/label/title. If the list is an actual section of content by itself or leads the section then using the heading to 'label' the list may well be best practice. There are likely other situations where <hn> list naming would also be appropriate.
7.5.5 Headings: The H1, H2, H3, H4, H5, H6 elements [w3.org]
A heading element briefly describes the topic of the section it introduces.
However, a section may contain one or more lists plus <p>s and <img>s, etc. wherein some other individual list identifying mechanism may be more useful. And as discussed there is an accepted methodology.
<hn>HEADER THIS SECTION</hn>
<dl>
<dt>A Term</dd>
<dd>A Description</dd>
</dl>
And a LIST
<hn>HEADER THIS SECTION</hn>
<ol>
<li>item1
<li>item2
</ol>
If content is that important it requires a title then insert inside an appropriate TABLE, complete with headers, captions, etc.
I suppose we could reinvent the wheel... but why? :)
We could NAME the sectioned list inside a DIV with a description.
There is a lot of unused power in lists.
Lists are indeed mighty handy. For the question posed, I kind of like <dl> with multiple <dd>.
Definition Lists [maxdesign.com.au]