You can use the ::before
or ::after
selectors to create a pseudo-element, and apply a content to it.
.matched::before {
content: "Matched";
}
.not-matched::before {
content: "Not Matched";
}
<table>
<tr>
<td class="matched"></td>
<td class="not-matched"></td>
</tr>
<tr>
<td class="matched"></td>
<td class="not-matched"></td>
</tr>
<tr>
<td class="matched"></td>
<td class="not-matched"></td>
</tr>
</table>
The downside of this is that those texts are not selectable.
You can also optimize the code like below:
[class]::before {
content: attr(class);
}
<table>
<tr>
<td class="matched"></td>
<td class="not-matched"></td>
</tr>
<tr>
<td class="matched"></td>
<td class="not-matched"></td>
</tr>
<tr>
<td class="matched"></td>
<td class="not-matched"></td>
</tr>
</table>
:after
or:before
come to mind.javascript
for this type of feature. In this case the text will be directly injected in the balise and not as a::after
element.