The spec describes <ol start=“”> and <li value=“”> as deprecated. (They are valid in HTML 4.01 Transitional and HTML5.) The spec also states:
Details about number order. In ordered lists, it is not possible to continue list numbering automatically from a previous list or to hide numbering of some list items. However, authors can reset the number of a list item by setting its value attribute. Numbering continues from the new value for subsequent list items.
Why does it say that when value=“” is deprecated in the very same section?
Sure enough, this code gives two errors when run through the validator, one for start=“” and one for value=“”:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<title>.</title>
<ol start="5"><li>foo<li value="8">bar<li>baz</ol>
I am confused as to why they were deprecated at all. Surely this is semantic information that is being lost; a list like <ol><li>NUL<li>SOH<li>ETX… is wrong semantically, whereas <ol start=“0”><li>NUL<li>SOH<li>ETX… is right semantically.
Is there a good way to account for this case using valid HTML 4.01 Strict?
This sounds like the only time when there is a really valid case for using HTML Transitional!
HTML5 allows the ‘start’ attribute … and also adds the ‘reversed’ attribute.
Of course, if you don’t care about older versions of IE, you could use content:before with a counter … but that seems like an awful lot of effort to go to just to avoid a trivial and inconsequential validation error!
Since the numbers actually have meaning you really ought to hard code them inside the <li> tags rather than relying on the <ol> applying the correct values. After all, adding an extra entry in the middle of the list should NOT change the existing numbers in this particular situation.
Is that CSS? If so, that would be wrong too, because CSS is not the layer for semantics. What if I’m viewing in Lynx? (I do that frequently!)
That seems strange to me but I can accept it. My reasoning was that it might be advantageous to use list-style-type to quickly view in decimal or hexadecimal, for example (doable in CSS3). Because the number representation itself (“10” vs. “0xA”) is not important, but rather the actual position in the list.
I get the feeling that the most appropriate‐yet‐still‐valid option here would be to use <dl><dt>0<dd>NUL<dt>1<dd>SOH<dt>2<dd>STX… instead.
Yes, the content:before is CSS. I had envisaged applying it to an <ol> and using CSS to hide the natural numbering - that way, anyone viewing with CSS would see the numbered list starting at 0, and anyone viewing without CSS would see the numbered list starting at 1, which at least is a numbered list, so preserving the semantics.
I get the feeling that the most appropriate yet still valid option here would be to use <dl><dt>0<dd>NUL<dt>1<dd>SOH<dt>2<dd>STX… instead.
I was wondering about that - if the number itself (in whatever representation) is inextricably linked with the letters then yes, maybe a <dl> would be the best way to go.
Otherwise, I would be quite happy to have that one page set as Transitional or HTML5 and have valid code that way.