I have the following code:
<div class="sidebar">1</div>
<div class="sidebar">2</div>
<div class="sidebar">3</div>
How do I use CSS to target the last div element? I’d like to change the styling if possible.
<div class="sidebar">3</div>
Sadly, I don’t have access to the HTML generated, so is this even possible?
Without having access to the HTML your best bet is to go with the
last-childCSS Selector.This assumes that the div is the last item in some parent element so that:
You could do: