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

Cupcake Project - Background Color Won't Show Up

Hi. I need help on the cupcake project. I wrote the CSS code for background color, but it will not show up on the web page. I checked through the forum but still cannot resolve this issue. Thanks. Here is my code so far:

body { font-family: 'Nunito', sans-serif; color: #FAF3BC; background: #420600 url('img/bg-texture.jpg') repeat; }

a { color: #49B69F; text-decoration: none; }

h1 { font-size: 1.750em; letter-spacing: -1.5px; }

h2 { font-size: 1.500em; color: #B4C34F; }

11 Answers

Hi Nicole, Is it just your background colour that isn't showing is your image displaying correctly ?

All the pictures are showing up fine (the ones I included in the HTML code). When I created the css style sheet and added background color, the color does not change on the web page. Thanks!

Have you linked your css file to your html file in the the head of the document ? something like this

<!doctype html>

  <head>

    <link rel="stylesheet" href="css/style.css" />

  </head>

just trying to start at the bottom and work up

Here is the html code of the head tag. Do I have everything correct?

<head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>Smells Like Bakin' Cupcake Company</title> <link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen"> <link rel="stylesheet" href="css/grid.css" type="text/css" media="screen"> <link href='http://fonts.googleapis.com/css?family=Nunito' rel='stylesheet' type='text/css'> <link rel="stylesheet" href="css/style.css" type="text/css" media="screen"> </head>

Because not only is the background not showing up, but all the code (text size and color) on the css sheet is not linking to the html index.

Hi Nicole. When I did that project the bg-texture image was in the img folder inside the css folder.

Try this:

body { font-family: 'Nunito', sans-serif; color: #FAF3BC; background: #420600 url('css/img/bg-texture.jpg') repeat; }

Thanks, Danielle. I tried that but it still won't work.

I just checked my stylesheet and I stand corrected. Your original code should work.

Nicole if you open the dev tools in Chrome (F12) > select elements and find your body tag. Then select Computed on the right. Scroll down and you should see the background image in the list of styles. It should show your bg file. If not your file might be in a different location than the one you specified in your background property.

Or do the same check under the resources tab, frames and keep expanding until you see images then check the list of images for you bg image.

Did that help?

I see the background image in the project folder css/img/ and it should link correctly. I just can't figure this out and I am new to this.

Im just on my phone so it's hard to see all the post but if you want to zip your files and send them to hind.anthony@sky.com looking at your last post try moving your Img folder out of the CSS folder so it is at the same level so you would have index.html then a CSS folder then an Img folder

Hi Nicole,

            <link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
            ``` 

Do you have the above link to your css file in the head of your document

In your css file style.css you should then have the following css code

  body {
  font-family: 'Nunito', sans-serif;
  color: #FAF3BC;
  background: #420600 url('img/bg-texture.jpg') repeat;
}
            ```