0

Can't get the syntax for :nth(3) selector on this a tag, in the 3rd li tag. What a mouthful. Is it even possible?

On this website

www.cutlassandcane.com/shopping/

I am trying to change the color of the 3rd menu item. Bandoli to have red font. It is prestashop so I cannot add span tags around it, asit was cause issues elsewhere.

So, my question is, is there a way to do it through CSS using the 3 rd child, or nth, selector?

.sf-menu a, .sf-menu a:visited  { /* visited pseudo selector so IE6 applies text colour*/
    color:black;
    font-size:14px;
}
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
kipper
  • 1
  • 2

2 Answers2

2

You can use :nth-child(), like this:

.sf-menu > li:nth-child(3) > a {
    color: #c0474c;    
}

Note that :nth-child() is only supported in modern browsers. It doesn't work in IE8 or lower.

thirtydot
  • 224,678
  • 48
  • 389
  • 349
  • thank you it worked. I used .sf-menu li:nth-child(3) a, because I didn't know what the ">" is for. What is the great than for? – kipper May 11 '12 at 20:44
  • It's the [child combinator](http://reference.sitepoint.com/css/childselector). It's supported in all modern browsers. You do need to use it in this instance, or you'll end up selecting elements that you don't intend to. – thirtydot May 11 '12 at 20:45
  • 1
    [Totally plugging this to answer OP's comment.](http://stackoverflow.com/questions/3225891/what-does-mean-in-css-rules/3225905#3225905) – BoltClock May 11 '12 at 23:20
1

Do you mean to say .sf-menu > li:nth-child(3) > a?

Alexander Pavlov
  • 31,598
  • 5
  • 67
  • 93
  • You're right of course. Without the child combinators, it also selects a bunch of the submenu links. I didn't notice one of them had a submenu. – thirtydot May 11 '12 at 17:11
  • Sorry, I was addressing the OP, not your solution :) Otherwise I'd have commented on the answer - for some reason I didn't get a timely "new answer added" notification... – Alexander Pavlov May 11 '12 at 17:17
  • I see, so this would have been if I had a submenu under Bandoli, but I don't so no harm no foul, BUT, good to know. THanks, it is working. – kipper May 11 '12 at 20:45