3

Possible Duplicate:
Number nested ordered lists in HTML

Apologies as I'm a bit of a css noob.

I have a list of terms and conditions.

The each section is numbered like this:

1.0 This Website
1.1 This website...
1.2 etc etc

2.0 ...
2.1 ...
2.2 ...

I know I can use an ordered list, but as I understand it the 'start' property is depreciated.

What alternatives have I got?

Community
  • 1
  • 1
dotnetnoob
  • 10,783
  • 20
  • 57
  • 103

3 Answers3

2

Stealing from Mozilla - Using CSS counters

JSFiddle

HTML:

<ol class="level0">
  <li>This Website
    <ol>
      <li>This website</li>
      <li>etc etc</li>
    </ol>
  </li>
  <li>...
    <ol>
      <li>...</li>
      <li>...</li>
    </ol>
  </li>
</ol>

CSS:

ol {
  counter-reset: section;
  list-style-type: none;
}

ol.level0 > li:before {
  counter-increment: section;
  content: counters(section, ".") ".0 ";
}

li:before {
  counter-increment: section;
  content: counters(section, ".") " ";
}
Olaf Dietsche
  • 72,253
  • 8
  • 102
  • 198
1

You can also use list-style-type css property.

ol { list-style-type: decimal; }
Ankur
  • 12,676
  • 7
  • 37
  • 67
1

You can use counter-increment for this. Write like this: HTML

<ol>
  <li>item 1
    <ol>
      <li>sub item 1</li>
      <li>Sub item 2</li>
   </ol>
  </li>
  <li>item 2
    <ol>
      <li>sub item 1</li>
      <li>Sub item 2</li>
   </ol>
  </li>
</ol>

CSS

ol {
  counter-reset: section;
  list-style-type: none;
}     
ol li { counter-increment: section; }

ol li:before  { content: counters(section, ".") ". "; }

Check this http://jsfiddle.net/xC8ne/10/

Check this for more Number nested ordered lists in HTML

Community
  • 1
  • 1
sandeep
  • 91,313
  • 23
  • 137
  • 155