tags:

views:

104

answers:

3

How to start ordered list from 2 not 1?

with all browser compatibility including IE6 and html css should bevalid

+2  A: 

this can be done directly via html with the start attribute

<ol start="2">
  <li>item two</li>
  <li>item three</li>
</ol>

it's not possible with only css, and it seems like IE doesn't support the start attribute …

knittl
@knittl - I checked on IE 8 and FF 3.5 it's working, just checked in IE 7 it's working
metal-gear-solid
You can also use `<li value="2">` for the first item, and all following items will continue from that number. The attribute is deprecated but I would still use it considering they haven't created any other alternative to it (how can you deprecate something without providing an alternative?).
animuson
@knittl - but it's being validated `<ol start="2">`
metal-gear-solid
@animuson - it also doesn't validate `<li value="2">`
metal-gear-solid
@metal-gear-solid: if it works, where's the problem?
knittl
@knittl - see my above comments
metal-gear-solid
Use Transitional DOCTYPE, `start`/`value` will validate. There is still some controversy over whether they should have been deprecated. They are back in HTML5.
bobince
A: 

Have you looked at this:

http://www.arraystudio.com/as-workshop/make-ol-list-start-from-number-different-than-1-using-css.html

EDIT: Strike that. Doesn't work in IE6. Sorry.

asgerhallas
+2  A: 

The easiest way I can see is to put the first LI in but hide it using css

adam
+1 Nice idea! -
Pekka
@adam - +1 for nice idea. Although it's not semantically correct and against to accessibility
metal-gear-solid
It is semantically correct and can be accessibility, depending on how you are going to use it.
adam
What is the meaning of blank `<li>.....</li>`?
metal-gear-solid
Don't make it empty. There must be a first item in the list, even if you are starting at #2. Put that first item in, then hide it. Like I said, accessibility depends on how you'll use it in your context
adam
but what we will put in empty li?
metal-gear-solid
It might help if we knew the context
adam