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) Understanding Values and Units Em Units

background-image

Hi,

I'm having trouble getting my background image to show up. What am I doing wrong?

Here is a copy of my syntax below.

HTML

<div id= "pic"> <p>Hello world and stars.</p> <p>This paragraph is not.</p> <p>Here are more cats for you.</p> <p>And no more.</p> </div>

CSS

#pic { background-image: url(img/spiritworld.jpg); color: red; }

4 Answers

In you css you have to place the path to your image inside quotations

#pic { 
background-image: url("img/spiritworld.jpg"); 
color: red; 
}

to reference an id in css you need the pound/hashtag/octothorpe (#) symbol, so here the selector would be #pic.

You have in your html a space between id= and "pic". The correct way is: id="pic" without space between.

i'm sorry when i copied the syntax i left out the # sign but it is in my css but will not show the image somehow.