Skip to content

Instantly share code, notes, and snippets.

@cdugeai
Forked from patik/styles.css
Last active October 7, 2023 12:39
Show Gist options
  • Save cdugeai/a75df87b388204be2cc41a91338160ea to your computer and use it in GitHub Desktop.
Save cdugeai/a75df87b388204be2cc41a91338160ea to your computer and use it in GitHub Desktop.
Numbered Headings in Markdown via CSS
body {
counter-reset: h1
}
h1 {
counter-reset: h2
}
h2 {
counter-reset: h3
}
h3 {
counter-reset: h4
}
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) ". "
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment