Ordered Lists with Nested Numbering
Can CSS produce ordered list items that appear as 1.1, 1.2, 1.3 instead of the default 1, 2, 3 sequence?
Solution Using Counters
To achieve this result, you can harness the power of CSS counters:
OL { counter-reset: item } LI { display: block } LI:before { content: counters(item, ".") " "; counter-increment: item }
The above style sheet initializes a counter called item for each
Example
<ol> <li>li element <ol> <li>sub li element</li> <li>sub li element</li> <li>sub li element</li> </ol> </li> <li>li element</li> <li>li element <ol> <li>sub li element</li> <li>sub li element</li> <li>sub li element</li> </ol> </li> </ol>
With the applied CSS, this HTML will render the list items with nested numbering as desired:
The above is the detailed content of How Can CSS Create Nested Ordered Lists with Numbering Like 1.1, 1.2, 1.3?. For more information, please follow other related articles on the PHP Chinese website!