Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Custom Counters</title> <style> ol.custom { list-style: none; counter-reset: section; padding-left: 0; } ol.custom li { counter-increment: section; padding: 6px 0 6px 40px; position: relative; } ol.custom li::before { content: counter(section, upper-roman) "."; position: absolute; left: 0; font-weight: bold; color: #c0392b; } /* Nested counters: 1.1, 1.2 ... */ ol.nested, ol.nested ol { list-style: none; counter-reset: item; } ol.nested li { counter-increment: item; } ol.nested li::before { content: counters(item, ".") " "; font-weight: bold; } </style> </head> <body> <ol class="custom"> <li>Introduction</li> <li>Main Content</li> <li>Conclusion</li> </ol> <ol class="nested"> <li>Chapter One <ol><li>Section A</li><li>Section B</li></ol> </li> <li>Chapter Two <ol><li>Section A</li></ol> </li> </ol> </body> </html>
Result
Open