Skip to content

Instantly share code, notes, and snippets.

@steffiland
Last active January 12, 2018 12:12
Show Gist options
  • Save steffiland/4022805e150720ac2329e88cf223f612 to your computer and use it in GitHub Desktop.
Save steffiland/4022805e150720ac2329e88cf223f612 to your computer and use it in GitHub Desktop.
CSS-auto-numbered headings for HTML documents
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Numbered Headings</title>
</head>
<body>
<style>
body {counter-reset: ebene1;}
h1:before {
content: counter(ebene1) " ";
counter-increment: ebene1;}
h1 {counter-reset: ebene2;}
h2:before {
content: counter(ebene1) "." counter(ebene2) " ";
counter-increment: ebene2;}
h2 {counter-reset: ebene3;}
h3:before {
content: counter(ebene1) "." counter(ebene2) "." counter(ebene3) " ";
counter-increment: ebene3;}
</style>
<h1>bla</h1>
<h2>bla</h2>
<h2>bla</h2>
<h1>bla</h1>
<h2>bla</h2>
<h3>bla</h3>
<h2>bla</h2>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment