[whatwg] Reverse ordered lists

Sam Arthur Allen dev at atshop3d.com
Wed Jan 23 06:23:20 PST 2008


On Wed, 23 Jan 2008 15:03:42 +0100
Lachlan Hunt <lachlan.hunt at lachy.id.au> wrote:

> Simon Pieters wrote:
> >    <ol start="100" reverse>
> > 
> > The lack of start='' would make the numbers update as the list is
> > filled with <li>s. This allows both for simplicitly for short lists
> > and correct incremental rendering for large lists.
> 
> No, the lack of an explicit start attribute would make it start from
> the default value: 1.  It would then count down from there:
> 
>   1. A
>   0. B
> -1. C
> -2. D
> 

Actually, the best route I can see is to not have a start attribute at
all but to rely on the browser to automatically detect the amount of
<li> tags within an
<ol reverse> container and decrement from there. ie:

   <ol reverse>   <-- Start count from here.
      <li>Red</li>
      <li>Orange</li>
      <li>Yellow</li>
      <li>Green</li>
      <li>Blue</li>
   </ol>   <-- Close tag detected, 5 <li> tags counted.

is rendered as starting from 5:

    5. Red
    4. Orange
    ...etc...

and using a "step" value, for example, all the browser would need to do
is multiply the total at the </ol> tag, and decrement that
multiplied total by the "step" amount, making:

   <ol reverse step="5">

render the list as:

  25. Red
  20. Orange
  15. Yellow
  ...etc...

It might mean more work for the browsers, but by experience something
like this isn't too hard to implement.



More information about the whatwg mailing list