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

HTML

I can't link my stylesheet with my index

I'm using atom and i wan't to link my stylesheet with my index my style sheet directory is: C:\Users\Electronixs\Documents\Prog\Html\JonathanPage\CSS\style.css and in my index.html i wrote <link rel="stylesheet" href="Html/JonathanPage/CSS/style.css"> and that still don't want to work, what's the problem

4 Answers

Based on the path you gave, is it safe to assume that your index.html is located in the c:\Users\Electronixs\Documents\Prog\ directory?

They reason I say this is that you href="" in the index.html file is starting to look from the current directory (the directory the index.html is in) and look for a folder named Prog....... down to the file.

So to clarify, what directory is your index.html file in?

So that means that your HTML and CSS directories (folders in windows) are both located in your JonathanPage directory.

What you would normally do is put your CSS directory inside your HTML directory and then you href="" link would read....

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

However....

If you'd like to keep the directory structure the way you have it then you'll need to link like this...

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

This will move up one folder, out of the HTML directory and into the JonathanPage directory and then go into the CSS directory and look for the style.css file.

Hope this helps!

my index.html is in C:\Users\Electronixs\Documents\Prog\Html\JonathanPage\HTML\Index.html

By the way my Style sheet look like that

body {
  font-family: "arial";
}

h1 {
  color: red;
}

and my index look like that

<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title="PhoenixCreation's"
  <link rel="stylesheet" href="CSS/style.css">
</head>
<body>
  <h1>Hi</h1>
</body>
</html>

As mentioned in my answer below, if you want to keep your code just move your CSS folder into the folder that your index.html file is in and it will work.

If you want to have your comment shown as code, and you are close to the correct syntax in your post.

make sure the opening 3 backticks are at the beginning of a new line, and the closing 3 backticks are on their own line as well.

Since you were referencing HTML and CSS you could put the text HTML or CSS directly after the first 3 backticks. You can also click the eye icon in the textbox you are writing your comments in to preview before posting.