Adrian Roselli on Nostr: Dusted this off for a use case where adding table row numbers server-side is not an ...
Dusted this off for a use case where adding table row numbers server-side is not an option and JS is overkill:
https://codepen.io/aardrian/pen/qEWrrOZ?editors=0100
If there is an empty cell starting a row, which is not a row header, then it inserts a counter (which starts at 0 so the row header gets excluded from the count).
```
table {
counter-reset: rowNum -1;
}
tr {
counter-increment: rowNum;
}
tr td:first-child:empty::before {
content: counter(rowNum);
}
```
#css
https://codepen.io/aardrian/pen/qEWrrOZ?editors=0100
If there is an empty cell starting a row, which is not a row header, then it inserts a counter (which starts at 0 so the row header gets excluded from the count).
```
table {
counter-reset: rowNum -1;
}
tr {
counter-increment: rowNum;
}
tr td:first-child:empty::before {
content: counter(rowNum);
}
```
#css