0

I have no idea why my CSS won't load, I've included the first part of my html.

Firebug and Chrome aren't giving me any issues loading the file.

Anyone know why this might be?

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://s3.amazonaws.com/codecademy-content/courses/ltp/css/bootstrap.css">
<script src='script.js'></script>
<link rel='stylesheet' href='style.css'/>
6
  • 1
    One or both of your CSS files won't load? It shouldn't matter, but you can also add type="text/css". Commented May 22, 2014 at 14:14
  • Adding type="text/css" is only another opportunity for a typo that breaks things. Commented May 22, 2014 at 14:15
  • 2
    is the path right? do you have the stylesheet in the same folder as the html file? of in an other folder? Commented May 22, 2014 at 14:15
  • 1
    check if your styles aren't Style.css or Bootstrap.css (I mean 1st letter capitalized). and look for the path of your files Commented May 22, 2014 at 14:19
  • path is right - when you check the url you are getting the css... Commented May 22, 2014 at 14:52

2 Answers 2

1

Not sure about all these:

As you don't say which of the CSS is wrong, it's a bit more complex to fix it, but checking the code you provide there are 3 possible or common issues that might be the reason your CSS isn't loaded:

  1. Your CSS file name has Uppercase names like: Style.css or Bootstrap.css
  2. Your path is wrong: ../styles/style.css might be one of the possible paths (as we don't have an image of the structure of your project I can't tell you how to do it in the correct way.
  3. You have <link rel='stylesheet' href='style.css'/> with 1 apostrophee instead of " quotation mark

I mean on the 3rd posibility that:

<link rel='stylesheet' href='style.css'/>

should become:

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

and adding type="text/css" as j08691 said, this should become the following code (also note that I deleted last / too):

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

And the same goes with the script, I mean quotation marks(") instead of apostrophees (')

EDIT

After looking at your site, your classes have a Capital letter name, like this one:

<div class="Header">

and your CSS file is:

.header {
    background-color: #BFBFBF;
}

there are 2 ways of solving it:

  1. Change your div class name to lower case names
  2. Change your style to capital letters.

And here's how it is after fixing it:

enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

It was the 'style.css' that won't load. I got rid of the capitalisation, changed the quotation marks, and I tried the linking that you suggested, neither worked. The file is definitely in the right place, and bootstrap loads, so I am really stumped as to what the issue at hand is.... Completley forgot, link to the site in question is canopyfoods.com
@user3665464 check my edit now and next time post a Fiddle with an MCVE with enough code that demonstrates the issue to make it easier to help you :)
0

It's loading just fine. If you go to your web site, open developer tools, and click on styles.css it's there.

So, that's not the problem.

The problem is your CSS isn't matching anything.

You have:

.header {...styles...}

But your HTML is:

<div class="Header">

It looks like you capitalized all your class names in your HTML, but not your CSS file.

(I just noticed Frakcool edited his answer while I was typing with the same observation. Do give Frakcool the credit for correct answer!)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.