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 trialMagdalena Misiuna
14,873 PointsI can not find a solution to make every 2nd letter in the heading a different color. Could you help?
I know I saw this in one of the CSS SElector tutorial, but can not find it :(
3 Answers
Steven Parker
231,269 PointsOnly the first letter has a pseudo-class (:first-letter
), so to style others you'll need to enclose them in an element like "span". For example:
<h1>S<span class="L2">a</span>mple heading</h1>
.L2 { color: red; }
Magdalena Misiuna
14,873 PointsI was hoping there is a way to avoid placing <span> on every second letter. Thank you so much for your help!
Steven Parker
231,269 PointsThere isn't currently. But there is a proposal for future CSS versions to have a ":nth-letter" pseudo-class that would do the trick!
Happy coding!
Magdalena Misiuna
14,873 Points:nth-letter, it would be a perfect solution! Thank you again.