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!
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 Foundation Stage 1 - Having trouble linking CSS to HTML File
So I'm in the beginning stages of CSS foundations and I am having trouble linking my CSS to my html. I have all both of my html (called "index") and css file (called "style") saved inside of a folder (called "Treehouse") on my desktop, so basically I'm trying to figure out what I'm doing wrong in linking them together. Below is my HTML link on the index file:
<!DOCTYPE html> <html> <head> <title>Adding CSS</title> <link rel=”stylesheet” href=”Treehouse/style.css” type="text/css"> </head> <body>
Steven Chin2,001 Points
Here is a template for an HTML page using stylesheets. Because you have not specified any markup, I am just placing here the general syntax:
<html lang="en"> <head> <!-- title of page --> <title>[Name of Page Goes Here]</title> <!-- style sheet linkage --> <link rel="stylesheet" type="text/css" href="[path to file]" /> </head> <body> ->[body content goes here]<- </body> </html>
Jason Nelson9,127 Points
<link rel="stylesheet" href="css/main.css">
You need have a link rel called stylesheet and a href pointing to where your css file is located.
Luis Magaña13,042 Points
All above is correct make sure you know where your stylesheet resides if its in the root with your index.html it should be <code>href="styles.css"</code> if its nested within a folder specify the folder <code>href="css/styles.css"</code>
Philippe Parmentier9,517 Points
from just reading your message, you wrote that both of your files are in the same folder.
or the path you wrote in your html is : Treehouse/style.css.
it is tricky because you would think it would recognize your Treehouse folder but it does not work that way.
here it just looking for a file in a directory called Treehouse where the index.html is.
when both files are at the same level(means the same directory folder), you just need to put : href="style.css"
if you want a file in a directory above Treehouse you can use "../" by exemple
try using the html editor brackets, it helps me finding the path to the files. good luck.
Okay I see where I went wrong I think I had the files nested and forgot to acknowledge that in the href code, thanks all for the help this is truly a helpful forum