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

Mark Bernard
Mark Bernard
2,746 Points

Order of declaration is not being accepted regardless of order?

Regardless of which value I set and the order I set, for the value of the property linear-gradient, it keeps showing as an error making passing the challenge impossible. Please help.

style.css
/* Complete the challenge by writing CSS below */
.main-header {
 background-image: linear-gradient (steelblue, darkslateblue 90%, bottom to top);
}
index.html
<!DOCTYPE html>
<html>
  <head>
    <title>Lake Tahoe</title>
    <link rel="stylesheet" href="page.css">
    <link rel="stylesheet" href="style.css">
  </head>
  <body> 
    <header id="top" class="main-header">
      <span class="title">Journey Through the Sierra Nevada Mountains</span>
      <h1 class="main-heading">Lake Tahoe, California</h1>
    </header>

        <div class="primary-content">
            <p class="intro">
                Lake Tahoe is one of the most breathtaking attractions located in California. It's home to a number of ski resorts, summer outdoor recreation, and tourist attractions. Snow and skiing are a significant part of the area's reputation.
            </p>
            <a class="callout" href="#more">Find out more</a>
        </div><!-- End .primary-content -->
  </body>
</html>

4 Answers

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

Hi there! I feel like you're doing pretty well but I cannot see all your attempts. I feel like you might have actually tried the correct code at one point with the exception that you've written bottom to top for the direction. But the correct direction should just read to top. The "bottom" part is understood.

So here's what I did:

 background-image: linear-gradient(to top, steelblue, darkslateblue 90%);

This defines a linear gradient going from the bottom to the top with the first color stop being "steelblue" and the second being "darkslateblue". The second stop is set at 90%.

Hope this helps! :sparkles:

Martin Lecke
Martin Lecke
14,385 Points
.main-header {
  background-image: linear-gradient(to top, steelblue, darkslateblue 90%);
}
linear-gradient( 
  [ <angle> | to <side-or-corner> ,]? <color-stop> [, <color-stop>]+ )
  \---------------------------------/ \----------------------------/
    Definition of the gradient line        List of color stops  

where <side-or-corner> = [left | right] || [top | bottom]
  and <color-stop>     = <color> [ <percentage> | <length> ]?
Mike Harrison
Mike Harrison
3,147 Points

You can also use "0deg" instead of "to top". This acts the same way.

.main-header {
background-image: linear-gradient(0deg, steelblue, darkslateblue 90%);  /*bottom to top */
background-image: linear-gradient(90deg, steelblue, darkslateblue 90%);  /*left to right*/
background-image: linear-gradient(180deg, steelblue, darkslateblue 90%);  /*top to bottom*/
background-image: linear-gradient(270deg, steelblue, darkslateblue 90%);  /*right to left*/
}
Mark Bernard
Mark Bernard
2,746 Points

thanks all for the help, I used the same types of declarations in the test but it just wouldn't work for me? Possible bug? Anyways I just copy and pasted the exact same code from your examples and it worked. Thanks to all.