0

I have this situation:

    <a href="...">
      <span>
         <svg>...</svg>
         A label
      </span>
    </a>

How can I select the "A label" text element (being the second child of the span element) in order to style it?

Is is possible somehow?

Michael Benjamin
  • 346,931
  • 104
  • 581
  • 701
aldobsom
  • 2,341
  • 1
  • 13
  • 13

1 Answers1

2

Set styles for the span element, and unset for its children:

.aSpan{
   color: red;
}

.aSpan > *{
   color: initial;
}
<a href="#">
  <span class="aSpan">
       <div>Not this</div>
         This
      </span>
</a>
symlink
  • 11,984
  • 7
  • 29
  • 50