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

troy beckett
troy beckett
12,035 Points

background img problem..

So I'm having a go at designing my own website for the first time and immediately I'm having problems with background. I put a background image full screen on my page but nothing is working.

Heres the css code I wrote now I know know this is nowhere near complete but I was expecting to see something happen on the page. but I got nothing.

My code:

html { background-image: url('images-1/grass-background.jpg');

}

How would you guys go about making a full browser size image background. Its annoying because I thought this bit was easy but I guess now I'm actually learning by doing.

troy beckett
troy beckett
12,035 Points

Yeah I read that before and I will read it again but I was just wondering if anyone has an idea why the code I wrote above did absolutely nothing. There must be something small I'm missing because w3 tell you to write it like this.

Felix Yakubov
Felix Yakubov
17,475 Points

try adding html {height:100%;} maybe folder is wrong as Andreas suggested,

2 Answers

Hi Troy

your code looks fine to me for the background image have you checked your path to your image. if your css file is in its own folder then your code should look like this

html{
  background-image: url('../images-1/grass-background.jpg') no-repeat;
  background-size:cover;
}

I have add the cover property to the background-size which scales the image without it looking blurred.

troy beckett
troy beckett
12,035 Points

I knew it was something small thanks alot for doing that really appreciated.