Created
December 2, 2013 15:39
-
-
Save ttscoff/7751322 to your computer and use it in GitHub Desktop.
Chapter numbers in CSS
This file contains hidden or 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
body { | |
counter-reset: chapter; /* create a chapter counter scope */ | |
} | |
h1:before { | |
content: "Chapter " counter(chapter) ". "; | |
counter-increment: chapter; /* add 1 to chapter */ | |
} | |
h1 { | |
counter-reset: subchapter; /* set section to 0 */ | |
} | |
h2:before { | |
content: counter(chapter) "." counter(subchapter) " "; | |
counter-increment: subchapter; | |
} | |
h2 { | |
counter-reset: section; | |
} | |
h3:before { | |
content: counter(chapter) "." counter(subchapter) "." counter(section) " "; | |
counter-increment: section; | |
} | |
h3 { | |
counter-reset: subsection; | |
} | |
h4:before { | |
content: counter(chapter) "." counter(subchapter) "." counter(section) "." counter(subsection) " "; | |
counter-increment: subsection; | |
} | |
h4 { | |
counter-reset: subsubsection; | |
} | |
h5:before { | |
content: counter(chapter) "." counter(subchapter) "." counter(section) "." counter(subsection) "." counter(subsubsection) " "; | |
counter-increment: subsubsection; | |
} | |
h5 { | |
counter-reset: subsubsubsection; | |
} | |
h6:before { | |
content: counter(chapter) "." counter(subchapter) "." counter(section) "." counter(subsection) "." counter(subsubsection) "." counter(subsubsubsection) " "; | |
counter-increment: subsubsubsection; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment