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

nth-of-type Question

I have to alternate between the color grey and the color blue for a day's schedule. I have to do this for an aside element.

For odd numbered h2 and paragraphs, I need to set the font color to rgb(79, 91, 40).

For even numbered h2 and paragraphs, I need to set the font color to rgb(81, 95, 175).

Below is my current code (Right now its making all the h2 blue, and all the paragraphs gray).

aside#tour_itinerary > h2:nth-child(odd){ color: rgb(255, 255, 255); }

aside#tour_itinerary > h2:nth-child(even){ color: rgb(81, 95, 175); }

aside#tour_itinerary > p:nth-child(even){ color: rgb(81, 95, 175); }

aside#tour_itinerary > p:nth-child(odd) { color: rgb(79, 91, 40); }

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! Ironically, the answer to your question is in your question. Your question contains nth-of-type, but it is nowhere to be found in your code. I took the liberty of making a codepen which does what I think you want it to. Take a look :smiley:

My codepen

Hope this helps! :sparkles:

Thank you Jennifer! You are right, it was included in the prompt and once I reread it, I realized it. Thank you for your response and aid.