<!DOCTYPE html>
<style>
.b:only-child {
color: green;
}
</style>
<p id="p"><span></span><span class="b">This text should be green.</span><span></span></p>
<script>
document.body.offsetTop;
p.removeChild(p.firstChild);
p.removeChild(p.lastChild);
</script>