counter

  • Supported by Opera 5.
  •  

    You can add counters to a style sheet and increment them each time a certain HTML element is found. This is useful for automatically printing chapter and paragraph numbers. Works only in combination with :before and :after.

    Test

    Testsheet:

    div:before {
    	counter-increment: div;
    	counter-reset: par;
    	content: "DIV number " counter(div) " ";
    }
    
    div p:before {
    	counter-increment: par;
    	content: "P number " counter(div) "." counter(par) " ";
    }
    
    This is a DIV

    containing a paragraph

    and yet another

    This is a second DIV

    containing a paragraph

    and yet another

    Contents