I am having trouble formatting text in a table where the second column contains text, with some rows having headings ranging from H1 to H5. I want to use auto numbering for the headings, but the increment function doesn't seem to be working within the table.
The issue is that the counter for H2 level is not increasing and it always shows as 1.1 for the heading number.
Can someone please help me identify the problem?
body {
counter-reset: h1counter;
}
h1 {
counter-reset: h2counter;
}
h2 {
counter-reset: h3counter;
}
h1:before {
counter-increment: h1counter;
content: counter(h1counter) ". ";
}
h2:before {
counter-increment: h2counter;
content: counter(h1counter) "."counter(h2counter) ". ";
}
h3:before {
counter-increment: h3counter;
content: counter(h1counter) "."counter(h2counter) "."counter(h3counter) ". ";
}
<table>
<tbody>
<tr>
<td>1</td>
<td>
<h1>Heading 1</h1>
</td>
</tr>
<tr>
<td>2</td>
<td>
<h2>Heading 1.1</h2>
</td>
</tr>
<tr>
<td>3</td>
<td>
<h2>Heading 1.2</h2>
</td>
</tr>
<tr>
<td>4</td>
<td>
<h1>Heading 2.</h1>
</td>
</tr>
</tbody>
</table>