JSFiddle - React, Tailwind, and code Playground
HTML
<ul>
<li>Bar</li>
<li>Bar</li>
<li>Bar</li>
<li>Should have a green background</li>
<li class='foo'>Bar</li>
</ul>
CSS
li:not(.foo):last-child {
background-color: green;
}
<ul>
<li>Bar</li>
<li>Bar</li>
<li>Bar</li>
<li>Should have a green background</li>
<li class='foo'>Bar</li>
</ul>
li:not(.foo):last-child {
background-color: green;
}