In the code snippet below, my goal is to apply a specific style to the content of the final occurrence of "B".
<div class="A">
<div>
I am <span class="B">foo</span>.
</div>
<div>
I like <span class="B">bars</span>.
</div>
<div>
Actually, call me <span class="B">FOOBAR</span>.
</div>
</div>
I've attempted
.B:last-of-type { color: red; }
and noticed all instances of class "B" are affected because it targets the last occurrence within its immediate parent's child elements or direct siblings.
Is there a method to exclusively select the final occurrence of "B" in the entire document?