I want to have after elements only if there are other elements after it. Here is my code so far:
<table id='table_1'>
<tr>
<td>A</td>
<td>B</td>
<td>C</td>
</tr>
</table>
Is it possible to have :after after A and B, but not C?
My CSS
#table_1 td:after{
content: "";
background: black;
border: 1px solid black;
position: relative;
margin-left: 10px;
}
Easiest way to do it is to use the not(:last-child):
#table_1 td:not(:last-child):after{
content: "";
background: black;
border: 1px solid black;
position: relative;
margin-left: 10px;
}
Working exmaple
That way you have only one selector and you don't need to override your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With