-
-
Save wardbeyens/9cbd9b9db9ddc0abe0cb2e048ed231b6 to your computer and use it in GitHub Desktop.
Numbered Headings in Markdown via CSS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
h1 { counter-reset: h2counter; } | |
h2 { counter-reset: h3counter; } | |
h3 { counter-reset: h4counter; } | |
h4 { counter-reset: h5counter; } | |
h5 { counter-reset: h6counter; } | |
h6 {} | |
h2:before { | |
counter-increment: h2counter; | |
content: counter(h2counter) ".\0000a0\0000a0"; | |
} | |
h3:before { | |
counter-increment: h3counter; | |
content: counter(h2counter) "." counter(h3counter) ".\0000a0\0000a0"; | |
} | |
h4:before { | |
counter-increment: h4counter; | |
content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) ".\0000a0\0000a0"; | |
} | |
h5:before { | |
counter-increment: h5counter; | |
content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) ".\0000a0\0000a0"; | |
} | |
h6:before { | |
counter-increment: h6counter; | |
content: counter(h2counter) "." counter(h3counter) "." counter(h4counter) "." counter(h5counter) "." counter(h6counter) ".\0000a0\0000a0"; | |
} | |
body { | |
counter-reset: h1 | |
} | |
h1 { | |
counter-reset: h2 | |
} | |
h2 { | |
counter-reset: h3 | |
} | |
h3 { | |
counter-reset: h4 | |
} | |
h4 { | |
counter-reset: h5 | |
} | |
h5 { | |
counter-reset: h6 | |
} | |
h1:before { | |
counter-increment: h1; | |
content: counter(h1) ". " | |
} | |
h2:before { | |
counter-increment: h2; | |
content: counter(h1) "." counter(h2) ". " | |
} | |
h3:before { | |
counter-increment: h3; | |
content: counter(h1) "." counter(h2) "." counter(h3) ". " | |
} | |
h4:before { | |
counter-increment: h4; | |
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) ". " | |
} | |
h5:before { | |
counter-increment: h5; | |
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5)". " | |
} | |
h6:before { | |
counter-increment: h4; | |
content: counter(h1) "." counter(h2) "." counter(h3) "." counter(h4) "." counter(h5) "." counter(h6)". " | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment