1

trying to target .product-price on-sale to change the color to green but i'm not able to.

HTML

<h2 id="product-price" itemprop="offers" itemscope itemtype="http://schema.org/Offer">
  <meta itemprop="priceCurrency" content="USD" />
  <link itemprop="availability" href="http://schema.org/InStock" />
  <span class="product-price on-sale" itemprop="price">$ 1</span>&nbsp;<del class="product-compare-price"></del>
</h2>

CSS

section#buy h2.product-price-on-sale span {
   color:green  !important;
}
1
  • span.product-price.on-sale { ... } should help. Commented Feb 23, 2015 at 16:36

4 Answers 4

2

With reference to your code this should work:

h2#product-price span.product-price.on-sale{
 color:green;
}
Sign up to request clarification or add additional context in comments.

Comments

1

Your CSS selector is wrong because your .product-price-on-sale class is on your span element not your h2. It should be

section#buy h2 .product-price.on-sale {
    color:green  !important;
}

Comments

0

A few problems with your selector:

section#buy h2.product-price-on-sale span

  • First part:

    section#buy

    It's ok assuming you have an extra wrapper with id buy

    <section id="buy">
    
  • Second part

    h2.product-price-on-sale

    Wrong since element h2 doesn't have a classname of product-price-on-sale instead has an id product-price, must be at this point:

    section#buy h2#product-price

  • Third part:

    span

    It's ok since the span element is inside the h2, but if you want to target the one with class product-price and on-sale your final selector must be:

    section#buy h2#product-price span.product-price.on-sale

Comments

0

class="product-price on-sale"
... h2.product-price-on-sale

You wrote it as two classes in the html and as one class in css (space vs dash). The css for two class selection is .class1.class2.

You also are not targeting the right tag, as pointed by other answers.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.