{"id":14033,"date":"2011-09-05T20:36:45","date_gmt":"2011-09-06T03:36:45","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14033"},"modified":"2019-01-31T07:24:07","modified_gmt":"2019-01-31T14:24:07","slug":"counter-increment","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/c\/counter-increment\/","title":{"rendered":"counter-increment"},"content":{"rendered":"

Ordered lists aren’t the only elements that can be automatically numbered. Thanks to the various counter-related properties, any element can be. <\/p>\n

<body>\r\n  <section><\/section>\r\n  <section><\/section>\r\n  <section><\/section>\r\n  <section><\/section>\r\n<\/body><\/code><\/pre>\n
body {\r\n  counter-reset: my-awesome-counter;\r\n}\r\nsection {\r\n  counter-increment: my-awesome-counter;\r\n}\r\nsection:before {\r\n  content: counter(my-awesome-counter);\r\n}<\/code><\/pre>\n

Each <section><\/code> will respectively start with “1”, “2”, “3”, or “4”. <\/p>\n

You can control the style of the counter by comma separating the counter function. e.g. to make them use Roman numerals:<\/p>\n

section:before {\r\n  content: counter(my-awesome-counter, upper-roman);\r\n}<\/code><\/pre>\n

Demo<\/h3>\n

On CodePen:<\/a><\/p>\n

<\/code><\/pre>\n

More Information<\/h3>\n