Tryit Editor v1.8

Source Code:
<!DOCTYPE html> <html> <head> <style> p { counter-increment: myIndex; } p:before { content:counter(myIndex); } </style> </head> <body> <p>First make a variable (myIndex) and make it increase every time a p element occurs.</p> <p>Then insert the counter in front of all p elements</p> <p><b>Note:</b> For the counter property to work in IE8, a DOCTYPE must be declared.</p> </body> </html>
Result:
W3Schools.com - Try it yourself