这个问题困扰我很久,突然看到这个文章

http://www.fiftyfoureleven.com/sandbox/weblog/2004/mar/lists-vs-divs/

Should we use lists instead of divs?Posted Mar-19-2004 Skip to the discussion (now closed): 2 comments

Via Tanketism in Anne Van Kesteren’s weblog, I found Absolute Lists: Alternatives to Divs.

In summary, the author suggests replacing your

s for lists, and then taming your lists with CSS, and states

This article discusses how to get rid of div elements altogether, and step into a world of pure semantics utilizing only lists for an entire page.

Now, why would we do this?

Because our content is really just a big list?

Because using can be confusing to user agents and so we need lists to present our ordered information?

Lets look at these individually.

Because our content is really just a big list

Now, from what the specs say about lists one could argue that the information contained in an html document is, if anything, “Ordered information”.

However, one look at example 1 from the article and its source code and it becomes obvious that this is just not semantically good.

A header and then it’s content on the next list item? In a nested unordered list no less? I feel like I’m heading back to tables!

Even if one could work out a sematically valid way of presenting this information (perhaps the header and it’s subsequent content held within the same

  • pair), do we need it?

    Because using can be confusing to user agents and so we need lists to present our ordered information

    Clearly something has been overlooked here, and part of what is missing can be found by reading Grouping elements: the DIV and SPAN elements from the W3C specs.

    s and s can be used for grouping elements in the document body.

    So now it begs the question: Is there something confusing to user-agents about the sequence of our documents?

    The specs say it all and there’s no reason to read further than the section about headings:

    A heading element briefly describes the topic of the section it introduces.

    No list required, when we venture to the next topic, we can use a header.

    As far as the order is concerned, right to left, top to bottom:

    lang="en" xml:lang="en">Summary

    In summary, there is no need to mark up traditional documents as lists. Using

    s to group (and style) common pieces of content is the correct way to do such a thing.

    Using headings and presenting content contained between headings from one logical thought to another takes care of the order of our document.



    Leave a reply