In CSS, how to create automatic section numbering only when there are multiple sections? I learned that one can create automatica numbering in front of sections by using CSS
body { counter-reset: section }
h2 { counter-reset: sub-section }
h3 { counter-reset: composite }
h4 { counter-reset: detail }
h2:before{
counter-increment: section;
content: counter(section) " ";
}
h3:before{
counter-increment: sub-section;
content: counter(section) "." counter(sub-section) " ";
}
h4:before{
counter-increment: composite;
content: counter(section) "." counter(sub-section) "." counter(composite) " ";
}
h5:before{
counter-increment: detail;
content: counter(section) "." counter(sub-section) "." counter(composite) "." counter(detail) " ";
}
which generate something like
1.1 XXX
for HTML
<h3>XXX</h3>
and something like
1.1 XXX
...
1.2 XXX2
for HTML
<h3>XXX</h3>
...
<h3>XXX2</h3>
But I want this numbering to be generated of course only when there are multiple <h3>
tags in the HTML. Is it possible to achieve that?