[thelist] Headers within ordered list in xhtml?

Douglas Clifton dwclifton at gmail.com
Tue Mar 1 10:37:36 CST 2005


I don't understand Bruce, by using the value attribute of the <li> item
you can start the (sub) list with what ever sequence you want. And why
everyone is so fixated on "semantics" is another topic that puzzles me.
90% of the markup out there is pure garbage.

1. Javascript is unreliable because anyone can disable it on the client-side
(I don't know what your audience is, but if it's the general public then...)
2. CSS 2.1+ has lots of feature to do exactly the sort of thing you're trying
here, and it's even "semantically" correct -- but the problem is lack of
support for generated content with the browser vendors. Take a look
at the:

counter
counter-reset
counter-increment

properties at the W3C page on CSS 2.1:

http://www.w3.org/TR/CSS21/generate.html#counters

for more info on CSS counters.

If the list is large, and you alter it frequently, then I suggest a server-side
solution to this. If you're familiar with PHP, then take a look at my help
page and view the source:

http://loadaveragezero.com/hnav/help.php
http://loadaveragezero.com/src/view/hnav/help.php

and even the resulting XHTML to see how I'm doing this, if on a somewhat
larger scale.

The entire table of contents, all nesting levels, all headings,sub-headings,
and links to those headings are automatically generated by the code. If I
change the data structure for the table of contents, the resulting page
automatically reflects these changes. All the styling is done with CSS.
And it works with IE, which has little if any support for CSS counters and
generated content in general.

Not to mention it's completely XHTML 1.1 valid.

Doug

On Tue, 1 Mar 2005 15:19:11 -0000, Bruce Lawson
<Bruce.Lawson at lawsociety.org.uk> wrote:
> Thanks Doug;
> I mis-expressed myself when I said , "I could break the list down into
> separate ordered lists,
> > interspersed with headings, but semantically it's *not* separate
> > lists, and I lose the value of the "auto-numbering" of the ol if I
> > have to restart the numbering manually with value attributes after the
> 
> > headings."
> 
> What I should've said is that "I lose the *utility* of the
> auto-numbering if I break my list into several <ol>s".
> 
> The point of my ordered list is that the numbers are recalculated
> automatically if I insert a new list item, but that automagic
> recalculation is lost as I'd need to do some mean DOM work to change the
> number in the value attribute of all the subsequent <ol> elements, or do
> it manually and forget/ get it wrong!
> 
> Also, I've a sort of allergic reaction to changing semantic markup to
> "fool" the validator into accepting my code; I'd joist as soon have a
> page of invalid code (I do the same when embedding Flash as I find the
> Flash satay method clever, but overly hacky).
> 
> Thanks for the ideas - and introducing me to the value attribute. Weird
> that it's deprecated but there's no way in css to tell an ordered list
> to start with a value other than 1, huh?


More information about the thelist mailing list