body {counter-reset: section; } h2 {padding-top: 2em; counter-increment: section; counter-reset: subsection;} h2:before {content: counter(section) ". ";} h3 {padding-top: 1em; } p { padding-left: 0.8em; } h3 {counter-reset: subsubsection;} h3:before { content: counter(section) "." counter(subsection) ". "; counter-increment: subsection; } h4:before { content: counter(section) "." counter(subsection) "." counter(subsubsection) ". "; counter-increment: subsubsection; }