Counter increment : counter increment « CSS « HTML / CSS

Counter increment


<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" lang="en" xml:lang="en">

  <title>CSS Counters</title>
<style type='text/css'>
body {counter-reset: chapter; counter-reset: section; }

h1:before {content: "Chapter " counter(chapter) ": "; }
h1 {counter-increment: chapter; counter-reset: section;}

h2:before { content: counter(chapter) "." counter(section) " "; }
h2 {counter-increment: section; }


<h1> Introducing Web Technologies</h1>
  <h2>Introducing HTML</h2>
  <h2>Introducing CSS</h2>
  <h2>Introducing XHTML</h2>
<h1> Structure of Documents</h1>


Related examples in the same category

1.counter-increment: paragraphNumber
2.LI counter-increment
3.List counter-increment: item
4.List counter-reset: item
5.Counter format