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 CSS Basics (2014) Enhancing the Design With CSS Gradients: Color Stops

Aaron Michael Ho
PLUS
Aaron Michael Ho
Courses Plus Student 1,299 Points

Color stops

Is there a maximum amount of color stops? Are we limited to three colors? Or could we "rainbow" the gradient. Also, is there a way to make a compound gradient?

1 Answer

Steven Parker
Steven Parker
231,275 Points

I don't think there's any specific limit on color stops, so you might make a rainbow gradient like this:

.rainbow {
    background: linear-gradient(to right,
        rgb(255,   0,   0) 0%,
        rgb(255, 255,   0) 15%,
        rgb(  0, 255,   0) 30%,
        rgb(  0, 255, 255) 50%,
        rgb(  0,   0, 255) 65%,
        rgb(255,   0, 255) 80%,
        rgb(255  , 0,   0) 100%);
)

Clearly, there's also no limit on 3 colors. And I'm not quite sure what you mean by a "compound" gradient. Would that rainbow be an example?

Aaron Michael Ho
Aaron Michael Ho
Courses Plus Student 1,299 Points

Thanks Steven! No limit on three colors...totally answered my question!

As to the other one re: the "compound" gradient...I suppose it would stop being a gradient at that point...but what I meant was a background that was a radial gradient that had areas of linear worked in. I imagine there's a way to do that, AND I also imagine it would take much more coding.

Steven Parker
Steven Parker
231,275 Points

More coding for sure, and it sounds like it might be a good application for SVG.