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.

Derick Moncado
Derick Moncado
23,103 Points

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 :)

bothxp
bothxp
16,429 Points

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.