Ordered lists, and how to break one up while still validating.

Discussion in 'HTML' started by Mike Barnard, Mar 23, 2008.

  1. Mike Barnard

    Mike Barnard Guest

    Yoohoo, it's me again.

    How do you do large ordered lists, if you need to break them up with
    headings yet still have it pass validation?


    This is an ordered list of 53 items, a breakdown of the 53 articles in
    a UK law. The list is continious but broken by part headings. On
    validation I get an error on each "Part1" "Part2" etc item;

    Line 285, Column 3: document type does not allow element "H4" here;
    assuming missing "LI" start-tag.

    I know what is wrong, I need to finish a list, do the heading then
    start a new list. So I need the new list to start an a number other
    than 1, where the previous list finished. The "start" property of the
    <ol> has been deprecieated but no matching CSS has been created.

    I have found a bodge for this at...
    .... but it's a bit long winded. What would you do?

    Leave it as it is? No validation but it works. (Must test in other
    browsers than FF! Have not done so yet. Must get Safari to load too.)

    Use the deprecieated 'start' property? No validation but *may* work in
    more browsers?

    Use the hack above? I will try it, but do you know of any problems
    with it?

    I look forward to having my eyes opened even wider! Happy Easter if
    Easter is your thing.
    Mike Barnard, Mar 23, 2008
    1. Advertisements

  2. Mike Barnard

    BootNic Guest

    Are you sure you need to restart the list?

    Let's see, what you have is something like this:


    I think you understand the error. However there is another way to go about
    doing what you want other then closing the list, add header then restart
    the list.

    What you can do is:


    BootNic, Mar 23, 2008
    1. Advertisements

  3. Mike Barnard

    Bergamot Guest

    That doesn't look very logical.

    If the list number really does need to resume on each list, it may be
    better to use the deprecated start attribute on the <ol> than resort to
    incorrect markup just to please the validator.

    Validated code is not an end to itself, though some people seem to think
    it is.

    A nested list would be correct, too, I think. Like a table of contents.

    <li><hx>Section heading</hx>
    <ol start="1">

    Looking at the page in question, though, I wonder what harm there is in
    letting the lists restart numbering at 1.
    Bergamot, Mar 23, 2008
  4. Mike Barnard

    Mike Barnard Guest

    Thanks Boot, I like the simple answers!
    Mike Barnard, Mar 23, 2008
  5. Scripsit Mike Barnard:
    Right, so use the "start" attribute.
    What do you mean by "No validation"? Validity is a formal thing, and a
    document validates if you use document type definition (DTD) that
    matches the actual markup. In this case, you can simply use HTML 4.01
    Transitional. Even if this were not the case, "No validation" would not
    be true; if you actually used an attribute not present in HTML
    specifications, then you could say "Nonconforming markup" or even
    (stretching the word "standard") "Nonstandard markup". But it would
    still be valid if and only if you use a DTD that allows the markup.

    Technically, the "start" attribute is presentational, so if it is
    _essential_ that the items be numbered in a particular way, you should
    put the numbers into actual content, e.g.
    <li>1. Text of the item</li>
    probably inside a <ul> element (since you dont want the
    browser-generated numbers that <ol> produces at least when CSS is off)
    with list-style-type: none.

    But in practice, I think it is fairly safe the treat "start" as
    semantic, i.e. to rely on the number being generated as specified by
    this attribute.
    Jukka K. Korpela, Mar 23, 2008
  6. Mike Barnard

    Mike Barnard Guest

    But, having tried it it works. It validates and works in all
    browsers, so far.
    Are there any browsers that ignore this deprecieated term, or wil it
    kick in to quirks mode? Dunno.
    It's a legal document that continues 1 to 53. The numbers match with
    the articles. Look at the link to the original and you'll see how they

    Mike Barnard, Mar 23, 2008
  7. Mike Barnard

    Bergamot Guest

    If it's valid in quirks mode, it will be supported even in standards
    mode. I don't know of any browsers that ignore deprecated stuff
    altogether. FWIW, I've always wondered why they deprecated the start
    attribute, since it's not really presentational. It's part of the
    content, at least to me.
    Quirks mode is only triggered by the doctype, not by anything else in
    the markup.
    OK, then I suggest using what makes sense for your particular document,
    not just what the validator wants.
    Bergamot, Mar 23, 2008
  8. Deprecated, Mike. Common scanning error. Just a heads-up.

    Appropriately for this holiday some celebrate, there are religious roots
    for the word: "[L. deprecatus, p. p. of deprecari to avert by prayer To
    pray against, as an evil; to seek to avert by prayer; to seek deliverance
    from; to express deep regret for; to desire the removal of."

    If prayer fails, you'll have to remove the offending markup by hand. :)
    Blinky the Shark, Mar 24, 2008
  9. Scripsit Bergamot:
    That's an absurd sentence, like "if 1 + 1 equals 2 when printed on
    paper". Validity is a formal property of a document. Nothing that a
    browser might do in displaying the document cannot change that.
    Wrong. The presence or absence of a comment, for example, before the
    doctype declaration is crucial on IE.
    The last part "not just what the validator wants" is very strange. Are
    you suggesting the use of invalid markup (which?), or are you just
    saying that validity is not sufficient (which should be pretty obvious
    Jukka K. Korpela, Mar 24, 2008
  10. Mike Barnard

    dorayme Guest

    First you make sure it is an ordered list. Just because a list has
    numbers does not mean it is ordered in the meaning of "ordered list".
    The meaning of order that is particularly relevant to an ordered list
    can be a tricky matter. The folk who made up the css on this cannot be
    blamed for not looking deeply into the matter, ordering and classifying
    being a very complex linguistic human activity. They rested content on
    probably no more than a couple of simple paradigms or examples. Thus:

    If a shopping list, for example, consisted of dry groceries and were to
    be purchased from a shop with a staff member behind a counter (as in the
    good old days), then the order is unlikely to matter. But it might
    matter if the items were to be purchased from different shops on a route
    that minimised energy. If it matters which order the person is to get
    things, then you would give an ordered list. If not, an unordered one.

    However there might be within the one list a couple of categories of
    things to be fetched, one in an order, the other in no particular order.
    The logical way to list the items here would depend very much on the
    exact circumstances. The main list might be an ordered one with suome
    sub lists within the order which are unordered.

    For example, your son should first take the dress item to be altered,
    and while it is being altered should second go fetch the dry groceries
    and third collect the dress item and take to dry cleaners for pressing.
    This would be a 3 item ordered list with the second item having a sub
    unordered list.

    You can easily imagine and and find cases far more complex. Sometimes it
    is quite a challenge to mark up. But the first thing is to settle what
    it is your material is really meaning.

    There are traps. The list might have numbers on them without being an
    ordered list, where it would be actually wrong to use an OL. An example,
    you send your son to the parts shop for some spare parts for something
    and the items are in fact labelled with product numbers. You happen to
    want consecutive numbers. It does not matter that it would be practical
    for mnemonic purposes to list them in order. It is still an unordered
    list. It does not matter what order the counter staff go off and fetch,
    how they pack them in your bag, etc. The point is that all the items are
    to be fetched in any order and they are all to be as specified. The
    number may be a way to identify the items. This is not an ordering
    matter but a matching matter. If you are wanting to use an html list,
    you would use a ul but put in the numbers as part of the text in the
    list item.

    Or you would use a table! I have argued on more than one occasion at
    some length that an ordered list is not more than a two column table in
    the sense that each is as semantically as appropriate as the other. An
    ordered list is not more than a 2 col table where the order is in one
    col and the item in the other, the headings being either specified to
    make clear what the number numbering means or else to be understood.

    Normally I would say an unordered list has no exact semantic table
    equivalent. But I make an exception for a special type of unordered
    list. One in which the numbers are an identifying feature of the item
    (rather than a call for action in the real world in a particular order -
    as in an algorithm). The spare parts example is appropriate here. The
    table would certainly be appropriate where the part number is on the
    left and the item description on the right, row by row a very tabular

    Be careful not to take on trust what is said to you on this Mike, think
    through it all. Ask yourself what do the numbers mean?

    You might conclude that the items you are dealing with *is* an ordered
    list. (I even have some considerations to lend weight to that, I have
    others, and more of them against it. But I won't trouble you with these
    specific things). I have not discussed this. But the mere presence of
    numbers is no guarantee. This does not mean you cannot lay things out as
    you want. You can still have numbers and letters and whatever you want
    as I have mentioned above, either in an unordered list or in a table).

    I mention all this stuff so you can pick the most intelligent tool for
    the job.
    dorayme, Mar 24, 2008
  11. Mike Barnard

    Andy Dingley Guest

    Then hard-code the numbers. Especially if they're references to paras
    in some other cited document. Especially so in this case because you
    know the numbers _are_ stable, i.e. skipping or duplicating a list
    element in your document should preserve the numbers uncanged, not re-
    number in sequence.

    Numbering of <ol> in HTML just doesn't work particularly flexibly.
    Attempts to make it work are amusing exercises for coders, but it's no
    way to get the job done.
    Andy Dingley, Mar 24, 2008
  12. Mike Barnard

    Ben C Guest

    Putting numbers on a list doesn't usually mean anything much about order
    because people number them in the order they're in anyway.

    No-one writes:

    3. Go home
    1. Go to shop
    2. Buy apples

    So you might just as well use bullets or nothing as write:

    1. Go to shop
    2. Buy apples
    3. Go home

    The main point of numbers is so you can refer to them. "In section 2,
    rotten apples are deprecated", etc.

    I think they're all like that really-- the numbers are just labels to
    refer to the items on the list.
    Ben C, Mar 24, 2008
  13. Mike Barnard

    Ben C Guest

    You should be able to use CSS to reset the counters (using counter-reset
    and counter-increment), but it isn't supported very widely. Opera
    manages it.

    Easier just to put the numbers in the <li>s as you suggest.
    Ben C, Mar 24, 2008
  14. Mike Barnard

    dorayme Guest

    Putting the numbers on either unordered or ordered lists is one thing.
    The list being ordered or unordered in its nature is another.

    Not necessarily. If the numbers are labels that have a meaning that is
    not a mere (and mostly not particularly useful) confirmation of the
    order on the page, then they might well be so written as in your first
    example. You can see this better if you *always* think in terms of a 2
    col table and ask yourself what would be in the head of the table over
    the number col. If "Shop number in the mall" was over it and you asked
    your son to fetch various things, you might well give him an ordered
    list - yes, an ordered one - but with "3" showing in the first row
    because shop 3 was in fact the shop you wanted him to go to first. The
    table rows, as they proceeded down would reflect the order you wanted or
    recommended your son to go in, the numbers being merely to identify
    something to do with the list item. Think my case of the dress
    alteration/dry cleaner example.

    I can't really agree with this as a general statement.

    If you mean by "they" in "they're all like that really" to refer to all
    lists that have numbers on them, then I disagree. In an ordered list the
    numbers are not "just" labels. They are a reflection of an important
    real world situation (actual, required or imagined). In an algorithm,
    for example, the order in which the list items are arranged is
    important. The actual numbers are not as important, they do have a
    labelling function.

    Consider how an ordered list might have no numbers

    <ol style="list-style: none;">

    (A rare sight because so many authors simply do not take the real
    distinction between an ordered and an unordered list seriously, most
    authors, I suspect (perhaps this is unfair? I do not refer to regulars
    here.) just think of an ordered list as a presentational device to get
    numbers up on the page.

    Just as an unordered one might have no numbers or even bullets, so too
    might an ordered one. They are different in meaning and this meaning
    might be very important. In a critical situation, it could mean the
    difference between life and death. Want examples?
    dorayme, Mar 24, 2008
  15. Mike Barnard

    Ben C Guest

    Certainly if the numbers aren't just in ascending order then they
    probably do mean something else. But it's rare that they aren't just in
    ascending order (and quite hard to get OLs not to just go up in
    ascending order).

    That's why I think that in most cases the only difference between
    numbers and bullets is that you can use the numbers to refer to the
    items in other text in the document. The list is usually ordered (even
    if arbitrarily) in only one way.
    Yes, any time you have some data for which you have two orderings. For

    3. Tom
    1. Dick
    2. Harry

    might mean Tom won at Boggle but came 3rd at Scrabble, etc.

    Well if the numbers are in the same order that the items are arranged on
    the page, then they aren't really saying anything.

    A list is either ordered or unordered in the sense of whether the order
    matters, and either kind of list can be written with numbers or bullets.

    If an ordered list is written with numbers, and the numbers are
    in-order, then surely they are just labels? The list is in order anyway.

    1. Light blue touchpaper
    2. Stand back

    doesn't mean anything different from:

    * Light blue touchpaper
    * Stand back

    They're both obviously ordered lists. The numbers are just labels.

    If the numbers aren't in the same order as the items' vertical positions
    then they aren't just labels, but then perhaps it's really a table and
    not just a list at all.
    Yes I can see an ordered list might have no numbers. But this just makes
    me more convinced than ever that the numbers are mere labels.

    If an ordered list can be written just as well with bullets, which it
    can, then using in-order numbers instead doesn't seem to be adding
    anything. Perhaps it emphasizes the order a bit? I don't even think it
    does, especially as one often numbers unordered lists.

    The only point I can see to in-order numbers is cross-referencing.
    That is my cynical view of OLs. But in that case they are misnamed--
    they should be called numbered and unnumbered lists, not ordered and
    unordered. Perhaps you're right, people should use OL/UL for
    ordered/unordered lists and decide whether they're numbered or get
    bullets with CSS.
    I can think of examples where doing things in the wrong order results in
    misadventure and death. Can you give an example where using in-order
    numbers rather than bullets (or the other way round) on either an
    unordered or ordered list could mean the difference between life and
    Ben C, Mar 24, 2008
  16. Mike Barnard

    dorayme Guest

    What is *really* a table and what is *really* a list is not a simple
    matter. An ordered list, and even some unordered lists are semantically
    not that different from 2 col tables with special headings. I have
    argued this a number of times. But please read on first.
    It all depends on quite what is meant by "mere labels". I don't think we
    are as far apart on this question of the numbers as might appear. We
    both agree that the presence of numbers or bullets do not alter the
    fundamental difference between two quite different types of list, the ol
    and the ul. You appear to lean toward the idea that they are almost
    gratuitous or else useful for later cross reference.

    The boy you sent to get the cheese with the unpronounceable and
    impossible to spell name will be relieved to tell his parent that the
    grocer said he did not have the item with the 15 in front of it. Even if
    the list was ordered!

    Whereas I am more wary of quite so downplaying them. The numbers are
    information to the user that the list is probably an ordered one, that
    the order is important. The numbers are *not* always mere labels. They
    are doing a semantic job that goes beyond simply linking the item to a

    In an ideal world in which ordered list were seen to be such, the
    numbers would not be needed except as mere labels (as they are in
    unordered ones).

    And so you will agree that it is sometimes crucial to know if a list is
    ordered or not. One indication (it is not 100% reliable because we both
    can see how unordered lists are sometimes also labelled) is the
    numbering rather than bulleting. This function is not for mere cross
    dorayme, Mar 25, 2008
  17. Mike Barnard

    dorayme Guest

    Perhaps, Ben, you might be a little more convinced that the numbers in
    an ordered list are not *mere labels* by the following consideration:
    imagine an ordered list that got printed out, damaged and broken up.
    You know from the context or from memory that the list critically
    ordered. You cannot reconstruct the order if the labels did not have an
    ordering meaning. If they were 1, 2, 3 etc this would immediately give
    you the order, first, second, third. If they were mere labels with no
    meaning at all (beyond a handy cross referencing device) you would be
    lost and it could result in a critical accident.

    This is why I say that the numbers in an ordered list, while not being
    necessary, are nevertheless more than mere labels as might be the case
    in an unordered list. One can deduce from the n-format label which is
    nth item in a list in a way one cannot deduce from an arbitrary-label
    which is the nth item in a list.
    dorayme, Mar 25, 2008
  18. Mike Barnard

    Ben C Guest

    I looked at the HTML spec and they do say UL is for data where the order
    isn't important and OL for when it is. Their example is the ingredients
    in a cake (unordered) and the instructions to make it (ordered).

    It then goes on to say that ordered lists are rendered with numbers,
    which are supposed to emphasize the order, like you're saying. So you
    aren't the only person who thinks this.

    Perhaps using bullets for ordered information is bad style if nothing
    else, since it could cause critical accidents.

    If someone pedantic is using numbers just as labels perhaps they should
    technically use an OL or even a DL and restyle it?
    Ben C, Mar 26, 2008
  19. Mike Barnard

    dorayme Guest

    Is your last "OL" a typo?

    Anyway, just talking to you about this has made me even more uneasy
    about the whole distinction as implemented in html and css. I am rather
    tempted by the view that there should never have been the distinction in
    the first place. I repeat that a couple of paradigm cases (see your
    reference to the examples used in the html specs) are just too thin a
    ground to rest this machinery on. (I say repeat because I have made the
    point before with other examples)

    Imagine no "ol" or "ul" in the first place in html, just "list". Keep it
    simple! Leave it to the context and the author to make it clear how
    important the order is.

    If you actually think about it, there are surely gradations of
    importance. By this I mean specifically that a list's order might be
    partly important and this will never ever be captured by meanings built
    into html elements. You could have a list that was ordered to an extent!
    And I am *not* meaning one that is so clear that it can be split into an
    ol with ul sub lists or vice versa. There may well be contexts where the
    author is simply unsure which order to put something in but knows that
    the order or rough order might be important.

    As in an algorithmic proposal to be experimented with by the reader.
    Sure the author might ol it and add a rider that the reader transpose
    the order to make the procedure do what he wants. Or he might ul it and
    add a rider that the order they are seeing on the page is roughly right
    (eg. you do not light the match first but you might put in the detonator
    before you add the right side panel to the box depending on the tools
    you have available or your dexterity). Never mind the details, I am
    saying that the distinction between ol and ul is really not all that
    useful in practice. It is a distracting straight jacket and impedes
    development. Authors should really be freed of having to worry about it.

    We would never be having this discussion, others would never be worried
    which to use where and when and so on. The context is often the best
    indicator of what is meant. I am saying that the html meanings here are
    nowhere near the power of contexts in their capacity to transmit
    dorayme, Mar 26, 2008
  20. Mike Barnard

    Ben C Guest

    Yes, I meant UL.
    The reality is many documents contain lists with either numbers or
    bullets. Word processors have a button for whether you want numbers or
    bullets. People expect to choose numbers or bullets. So that's what you
    got in HTML and they were called UL and OL, even if that's not what
    they're supposed to mean.

    Now that you can style either how you like perhaps just one kind of list
    would be better, although it's more convenient just to leave it how it
    They never are. The criterion for choosing a tag can't reasonably be
    anything more strict than: is there a better tag I could have used from
    the choice available?
    Ben C, Mar 26, 2008
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.