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

Have been trying for hours to add a background to my header but I just can't seem to get it.

header { text-align: center; background-image: url(img src='../images/montserrat.jpg'); no-repeat top center ; background-size: cover; overflow: hidden; padding-top: 60px; }

Have you tried removing the invalid stuff img src= from your url property?

(from MDN) - The <url> data type is specified using the url() functional notation. It may be written without quotes, or surrounded by single or double quotes. Relative URLs are allowed, and are relative to the URL of the stylesheet (not to the URL of the web page).

You don't want to copy your whole img element, just the path portion.

Please try url('../images/montserrat.jpg')

There are other syntax errors in your original rule.

What does your statement looks like now? Did you also fix the missing properties forno-repeat top center. Maybe try thebackgroundshorthand withbackground: no-repeat center url('../images/montserrat.jpg');`

4 Answers

Are you sure that img and src = are valid within the url()? url(img src='../images/montserrat.jpg');

Hi Kevin,

When I copy paste your code in codepen it renders just fine. So it's like Dave says: your pathing is wrong. Also make sure to check if your image contains any capitals and whether or not the filetype (.jpg, .png, .gif...) is correct.

Good luck, Max

Don't really understand. It is the same path that I used for the profile image and it's working fine. Still not sure what I'm missing in order to make the image appear in the background.

I have and I’m still getting the same result

Wrote it exactly how you have it and the image is still not showing up.