{"id":33386,"date":"2016-04-04T16:18:24","date_gmt":"2016-04-04T10:48:24","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=33386"},"modified":"2017-09-12T12:44:58","modified_gmt":"2017-09-12T07:14:58","slug":"creating-automatic-numbering-with-css-counter","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/creating-automatic-numbering-with-css-counter\/","title":{"rendered":"Creating Automatic Numbering with CSS Counter"},"content":{"rendered":"<p>As you know, in\u00a0<span data-sheets-value=\"{&quot;1&quot;:2,&quot;2&quot;:&quot;front end development&quot;}\" data-sheets-userformat=\"{&quot;2&quot;:14720,&quot;10&quot;:2,&quot;11&quot;:0,&quot;14&quot;:[null,2,0],&quot;15&quot;:&quot;Calibri&quot;,&quot;16&quot;:11}\"><a title=\"front end development\" href=\"http:\/\/www.tothenew.com\/front-end-angularjs-development\">front end development<\/a>\u00a0<\/span>when we add lists to the &lt;ol&gt; element, a numbered list gets generated automatically.<\/p>\n<p>Similarly, we can generate numbers for any element using CSS Counter. Let&#8217;s see how it is done?<\/p>\n<h3>Usage:<\/h3>\n<p>CSS Counter has two main properties: &#8220;counter-reset&#8221; and &#8220;counter-increment&#8221;.<\/p>\n<p>The following code is an example of how we number a &lt;h1&gt; element with these properties.<\/p>\n<p>[java]body {<br \/>\n\tcounter-reset: number;<br \/>\n}<br \/>\nh1:before {<br \/>\n\tcounter-increment: number;<br \/>\n\tcontent: counter(number) &quot; &quot;;<br \/>\n}[\/java]<\/p>\n<p>Here is the image that shows the number of &lt;h1&gt;.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-33388\" style=\"border: 1px solid #e1e1e1; padding: 10px; width: 100%;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/04\/img1.jpg\" alt=\"img1\" width=\"696\" height=\"323\" \/><\/p>\n<p>In case you want the number to start from specific number, you can specify the &#8220;reset number&#8221; as follows:<\/p>\n<p>[java]body {<br \/>\n    counter-reset: number 1;<br \/>\n}[\/java]<\/p>\n<p>If the reset number is not declared clearly it will be set it as 0 as default, and the count will start from 1.<\/p>\n<p>Similarly, the numbering\u00a0will start from the next number to\u00a0the one in the counter-reset property. So, as per given example code above, the count will start from 2.<\/p>\n<p>Here is the image that show the number of &lt;h1&gt; starting from 2.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-33389\" style=\"border: 1px solid #e1e1e1; padding: 10px; width: 100%;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/04\/img2.jpg\" alt=\"img2\" width=\"696\" height=\"323\" \/><\/p>\n<p>Even, you can also change the type of the number, which is specified within the content property.<\/p>\n<p>[java]h2:before {<br \/>\n    counter-increment: first;<br \/>\n    content: counter(number, upper-roman) &quot;. &quot;;<br \/>\n}[\/java]<\/p>\n<p>Here is the image that shows the roman number of &lt;h1&gt;.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-33391\" style=\"border: 1px solid #e1e1e1; padding: 10px; width: 100%;\" src=\"\/blog\/wp-ttn-blog\/uploads\/2016\/04\/img3.jpg\" alt=\"img3\" width=\"696\" height=\"323\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As you know, in\u00a0front end development\u00a0when we add lists to the &lt;ol&gt; element, a numbered list gets generated automatically. Similarly, we can generate numbers for any element using CSS Counter. Let&#8217;s see how it is done? Usage: CSS Counter has two main properties: &#8220;counter-reset&#8221; and &#8220;counter-increment&#8221;. The following code is an example of how we [&hellip;]<\/p>\n","protected":false},"author":206,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":4},"categories":[3429],"tags":[3177,3174,3176,3175],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/33386"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/206"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=33386"}],"version-history":[{"count":2,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/33386\/revisions"}],"predecessor-version":[{"id":51799,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/33386\/revisions\/51799"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=33386"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=33386"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=33386"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}