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

Linking CSS stylesheet to index.html

This might be obvious BUT I can't identify why my stylesheet is not linking to html. Here's the code:

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

10 Answers

Got it. Odd...had to recreate my workspace and copy and paste everything back in.

You're forgetting the 'type' attribute. Also you'll most likely want to get rid of those spaces after your rel and href attributes too, also check to see if your path is correct. Should look something like this:

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

Hope this helps :)

That was my 1st through, but the extra whitespace shouldn't make a difference and you often see the type attribute left off.

Have you checked if the path to the stylesheets is correct?

Grayson Sabin
Grayson Sabin
6,911 Points

try adding type="text/css

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

or check to make sure you have a folder named css and a file in it named main.css

Thanks everyone! Unfortunately, adding type="text/css" did not work. I am pretty sure that the path to the stylesheet is correct. I have a folder titled css with files named normalize.css and main.css. I'm stumped.

Grayson Sabin
Grayson Sabin
6,911 Points

How are you viewing your site? locally or on server?

also is your index.html in your root folder? same as where the css folder is?

Viewing locally. And yes, all in the same folder!

Can you post the complete code in the head section of your index.html?

  <head>
    <meta charset= "utf-8">
    <title> NAHS </title>
    <link rel="stylesheet" type="text/css" href="css/normalize.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">
  </head>

Must have been a bug. Glad you got everything to work.