1

I want to create a ordered html list like this:

1.0 Introduction

1.1 Features

1.2 Readme

1.3 Thanks

...

How do I do this with html?

Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
bodokaiser
  • 15,122
  • 22
  • 97
  • 140
  • possible duplicate of [Number nested ordered lists in HTML](http://stackoverflow.com/questions/2729927/number-nested-ordered-lists-in-html) – Jukka K. Korpela Mar 29 '12 at 18:00

3 Answers3

2

Counter's are the way to go. See this fiddle which goes three levels deep.

ScottS
  • 71,703
  • 13
  • 126
  • 146
1

You'll need to use the CSS counter-increment (and possibly the counter-reset) property.

http://www.w3schools.com/cssref/pr_gen_counter-increment.asp

Matt
  • 1,897
  • 4
  • 28
  • 49
  • Hi, I have a lot of sub lists. This would be very chaotic with resetting everything via css. Are there some nices solutions? – bodokaiser Mar 29 '12 at 18:02
  • You can attach a CSS class to each item in the list and sub-list (see this example: http://www.w3schools.com/cssref/tryit.asp?filename=trycss_gen_counter-reset). I'm not exactly sure what qualifies as a "nicer" solution as now I'm not sure of the ultimate task you're trying to solve. – Matt Mar 29 '12 at 18:04
  • Hi, If I have this structure:
      1. What do I have to do. I don't understand the reference Regards
    – bodokaiser Mar 29 '12 at 18:10
0

Your question is answered here

Can ordered list produce result that looks like 1.1, 1.2, 1.3 (instead of just 1, 2, 3, ...) with css?

The following style sheet numbers nested list items as "1", "1.1", "1.1.1", etc.

OL { counter-reset: item }
LI { display: block }
LI:before { content: counters(item, ".") " "; counter-increment: item }

Maybe you can edit your question to avoid duplicating questions. Pointing to that one I just told you.

Bruno João
  • 5,105
  • 2
  • 21
  • 26