Number chapters and sections with "Chapter 1", "1.1", "1.2", etc. - HTML CSS CSS Property

HTML CSS examples for CSS Property:counter-increment

Description

Number chapters and sections with "Chapter 1", "1.1", "1.2", etc.

Demo Code

ResultView the demo in separate window

<html>
   <head>

      <style&gtl;
         body {<!--  ww w.j ava 2 s  . c  o m-->
            counter-reset: section;
         }
         h1 {
            counter-reset: subsection;
         }
         h1:before {
            counter-increment: section;
            content: "Section " counter(section) ". ";
         }
         h2:before {
            counter-increment: subsection;
            content: counter(section) "." counter(subsection) " ";
         }
      </style>

   </head>
   <body>

      <h1> book 2s .com</h1>
      <h2> book 2s .com</h2>
      <h2> book 2s .com</h2>
      <h2> book 2s .com</h2>
      <h2> book 2s .com</h2>

   </body>
</html>

Related Tutorials