Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS nth-child – I can’t select a link on a list

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #34370
    elarellano
    Member

    Hy fellows (my first post on the forum)

    I want to use nth-child to style each list item differently. It works for me when is just a list. But I don’t know how to select it when its a link there

    CSS

     nav ul li:nth-child(2)  { color: white ;
    }

    html

    		 	 

    Thanks in advance.

    #87309
    TheDoc
    Member

    Here you go! Very simple – just have to add the ‘a’ after li:nth-child(2)!

    http://jsfiddle.net/hL5GE/

    #87314
    elarellano
    Member

    Oh Thanks Doc.

    #296709
    CBianca
    Participant

    Why doesn’t it work when I use 3rd?
    I used ul li:nth-child(3rd) ..
    Thanks!

    #296710
    CBianca
    Participant

    And sorry for my stupid question..
    It tooks me an hour to discover this answer

    #296712
    nicecss
    Participant

    Here you go! Very simple – just have to add the ‘a’ after li:nth-child(2)!

    http://jsfiddle.net/hL5GE/

    Thanks! Very useful tools. Why haven’t I used it before? I see that I can choose the framework and even its version. Bookmarked!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘CSS’ is closed to new topics and replies.