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 Foundations Backgrounds and Borders Background Properties

Sean Flanagan
Sean Flanagan
33,235 Points

No background colours

Hi.

Can anyone tell me please why I can't get my background colour?

HTML:

<!DOCTYPE html>
<html>
<head>
    <title>Background Properties</title>
    <link rel="stylesheet" href="page-styles.css">
    <link rel="stylesheet" href="css/css_foundations_style.css">
</head>
<body>
    <div class="box"></div>
</body>
</html>

CSS:

.box {
    background-color: blue;
}

Thanks.

7 Answers

Hi Sean

Type some text within the div you will see the background.```html <!DOCTYPE html> <html> <head> <title>Background Properties</title> <link rel="stylesheet" href="css/css_foundations_style.css"> </head> <body> <div class="box"> This is a test </div> </body> </html>

what is the name of your style sheet the first link or the second one?? if its the first one your link should be

html <link rel="stylesheet" href="css/page-styles.css">

your CSS looks fine hence it can only be the link to your style sheet.

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Andreas. I use the css_foundations sheet. I've deleted the page-styles sheet, but I still get only a white screen.

<!DOCTYPE html>
<html>
<head>
    <title>Background Properties</title>
    <link rel="stylesheet" href="css/css_foundations_style.css">
</head>
<body>
    <div class="box"></div>
</body>
</html>

Try:

<link rel="stylesheet" type="text/css" href="css/css_foundations_style.css">

maybe the " type="text/css" " is missing

Because there is no content inside the div.

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Christoph. I added 'type="text/css" but nothing changed.

Hi Partha. I typed in the div line exactly as Guil instructed. It worked for Guil but not for me. So I'm still confused. When Guil refreshed his browser, the big frame appeared in the middle of the screen, but when I refreshed mine, nothing happened.

I don't know what to do.

Cheers

Sean

Sean Flanagan
Sean Flanagan
33,235 Points

Hi Andreas.

I've typed text within the div, as per your suggestion and it's worked. Thank you.

Sean