michaelmcgurk
michaelmcgurk

Reputation: 6509

Target this element with CSS?

Using nth-child, how would I style the <span class=field-content>Martin McGurk</span> from the following HTML:

<div id="callout" class="owl-carousel">
 <p>
  <span class=field-content>Good service...</span>
  <span>
   <span class=field-content>Martin McGurk</span>
  </span>
 </p>
</div>

Upvotes: 0

Views: 36

Answers (1)

Praveen Kumar Purushothaman
Praveen Kumar Purushothaman

Reputation: 167162

I would say, go with:

#callout span .field-content {background: #0cf;}
<div id="callout" class="owl-carousel">
  <p>
    <span class=field-content>Good service...</span>
    <span>
      <span class=field-content>Martin McGurk</span>
    </span>
  </p>
</div>

Or, if you really prefer :nth-child, use:

#callout span:nth-child(2) .field-content {background: #0cf;}
<div id="callout" class="owl-carousel">
  <p>
    <span class=field-content>Good service...</span>
    <span>
      <span class=field-content>Martin McGurk</span>
    </span>
  </p>
</div>

Upvotes: 1

Related Questions