Numbered sections in a long guide go wrong the moment you insert one in the middle. CSS counters let the browser do the counting.
article { counter-reset: h2; }
article h2 {
counter-increment: h2;
counter-reset: h3;
}
article h2::before { content: counter(h2) ". "; }
article h3 { counter-increment: h3; }
article h3::before { content: counter(h2) "." counter(h3) " "; }
counter-reset creates a counter (starting at 0), counter-increment adds one each time an element matches, and counter() prints the current value in generated content. Each h2 also resets the h3 counter, so subsections start again at 1 under every new section. The result reads 1., 1.1, 1.2, 2., 2.1 and so on.
You can change the style too: counter(h2, upper-roman) gives I, II, III.
The numbers are generated content, so they are not part of the DOM text. Copying a heading leaves the number out, and a table of contents built by a script from the heading text will not show them. If the numbers matter outside the page, for example because people refer to “section 3.2” in emails, write them into the HTML instead.
Further reading: MDN: Using CSS counters