Replacement for deprecated OL/LI start/value HTML attributes
Posted on 7th September 2009 in CSS, Open Standards | 2 Comments »
As by the HTML 4.01 specification, all attribute definitions of lists, such as ordered lists and unordered lists, are deprecated, meaning that you can’t make a list purely in HTML that would skip some numbers, e.g. 1, 2, 3, 5 skipping 4. Previously you could use start or value attribute to set a value for the list item. Now, as the attributes have became deprecated, any self-respecting coder would expect CSS to kick in with the alternative. Unfortunately, this is not the case.
Now, in more detail, the goal would be to get a list that looks like this:

So let’s turn to CSS 2.1 specs for help. Currently, what lists have, is this:
- list-style (shorthand)
- list-style-image
- list-style-position
- list-style-type
Pretty simple and no replacement for the start/value attributes. So a fully valid HTML 4 / CSS 2.1 approach leaves us with the possible workaround:
<ol> <li>Winner</li> <li>Runner-up</li> <li>Chap who came 3rd</li> <li style="list-style-type: none;">Another chap who shares the 3rd place</li> <li>A bloke who came 5th</li> </ol>
Which would render like this:
- Winner
- Runner-up
- Chap who came 3rd
- Another chap who shares the 3rd place
- A bloke who came 5th
The above is fine, it works, but code-wise it’s not quite right. There’s still no 4 in the list, but it’s not showing.
Unfortunately there’s no straightforward replacement mechanism in CSS 3 either. Similarly, there’s no solution for the legal lists.
Let’s hope W3C will revise it at some point.
References:


2 Responses
Your solution doesn’t work in non-CSS browsers like Lynx (yes, I once had to use Lynx as it was not possible to use a graphical browser; obviously some sites were very hard to navigate).
The HTML 5 Working Draft has support included for the start and value attributes, without marking them as deprecated.
Technically, what you have above is correct for your context. If two (or more) people share a place like that, then subsequent places tend to be removed, thus there would be no 4th place.
However what you’re trying to illustrate, that the numbers go out of sequence if you remove the list-style, is obviously not ideal for most situations.