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


I'm trying to build my website and my css is not working

Here is my HTML:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Gary Christie's Weight Loss Journey</title> <link rel= "stylesheet" href= "main.css"> </head>
<body> </body> </html>

Now here is my CSS. Very simple and nothing won't happen so far. What am I doing wrong?:

body { background: black; }

So basically I am trying to put my background black and its not happening. Both HTML and CSS are in the same folder. Originally I tried to put a image for a background and that wouldn't appear on the screen. After fighting with it for so long I decided do a black background. That is not working neither now

From what you have posted it looks like you have not linked your style sheet and/or included it in your .html file.

here is a link from w3schools on the 3 ways to hook up your css.


2 Answers

Yulia Markina
Yulia Markina
12,616 Points

Hi Gary! Make sure you've linked css file. It should look like this. I put main.css as the name of the file as an example.

    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="main.css">
    <title>Gary Christie's Weight Loss Journey</title>

Shawn is right it looks like you need to link you css to you html file.

        <link rel="stylesheet" href="main.css">