Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to achieve decimal numbering in ordered lists? [duplicate]

Tags:

html

css

With HTML and CSS, can I achieve this?

1.
1.1
1.2
2.
2.1
2.2

using <li> and <ul> tags?

like image 731
78lro Avatar asked Jun 05 '09 14:06

78lro


People also ask

How can you make a numbered ordered list?

Ordered list starts with the <ol> tag. The list item starts with the <li> tag and will be marked as numbers, lowercase letters uppercase letters, roman letters, etc. The default numbers for list items. For creating an ordered list with numbers, use the <ol> tag attribute type.

How many types of numbering can be done in ordered list?

There can be different types of numbered list: Numeric Number (1, 2, 3) Capital Roman Number (I II III) Small Romal Number (i ii iii)

Can you change the style of numbers in an ordered list?

Answer: Type attribute allows us to change the style of numbers in an ordered list. Explanation: The < li > tag includes two attributes – type and value. The type attribute is used to modify the order numbering in the list item.


1 Answers

For CSS-compliant browsers you could use:

ul { counter-reset:item; }
ul > li { counter-increment:item; }
ul > li:before {content: counter(item); }

ul > li > ul { counter-reset:subitem; }
ul > li > ul > li { counter-increment:subitem; }
ul > li > ul > li:before { content: counter(item) "." counter(subitem); }
like image 177
dan richardson Avatar answered Sep 20 '22 13:09

dan richardson