Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS

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.

http://www.w3schools.com/css/css_howto.asp

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.

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

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

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