I am trying to create a table using a function and it currently looks like this:
table {
border: 1px solid;
}
td {
width: 30px;
height: 30px;
text-align: center;
}
<table>
<tr>
<td>2</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>0</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>0</td>
</tr>
I want to add borders around the cells that contain non-zero values only. How can I achieve this? Can it be done using just CSS?