Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

More then one number in nth-child?

Is it possible to select multiply numbers with nth-child pseudo-class? For instance I would like to select item 3 and item 6.

   <ul>
        <li>Item 1</li>
        <li>Item 2</li>
        <li>Item 3</li>
        <li>Item 4</li>
        <li>Item 5</li>
        <li>Item 6</li>
        <li>Item 7</li>
        <li>Item 8</li>
        <li>Item 9</li>
        <li>Item 10</li>        
    </ul>
li:nth-child(6, 3)  {
 background:  #52bab3;
  color: #fff ;
}

1 Answer

james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

you can just make two selectors, one for 3 and one for 6

li:nth-child(3), li:nth-child(6)

or using negative numbers you can start at any item and go backwards toward the start, and just start at 6 and apply to every 3rd item, so it would be 6 and 3.

Thank you James!