views:

222

answers:

5

I have a weird, annoying problem. I have a css/ folder and index.html at the root. I load css files in the header as follows:

<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
    <title>blabla</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <meta name="keywords" content="keywords" />
    <meta name="description" content="desc" />

    <!-- style files -->
    <link rel="stylesheet" type="text/css" href="css/reset.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/layout.css" media="screen" />
    <link rel="stylesheet" type="text/css" href="css/global.css" media="screen" />
</head>

but the css is not working: I see a plain index.html. I'm sure the css path is right; when I click "view source" and copy/paste the css files path, it shows the css files.

Also, when I copy the css directly into index.html, it works. What could be the problem?

+1  A: 

Try Firefox and Firebug. Have a look in the error console; maybe it's just a small typo.

Aaron Digulla
Won't show in the error console, but in the NET tab
Bart van Heukelom
hmm, it says "304 Not Modified" for css files. at Firebug Net tab
artmania
304 means that the browser already has the CSS in the cache and thinks it's up-to-date. Try to clear the browser cache.
Aaron Digulla
A: 

Try removing the media attribute. I dont know if that would affect it but its worth a try.

Ozzy
+1  A: 

Probably not served as text/css. Did you check your server config?

jensgram
+2  A: 

The relative URL is likely wrong. To help you further we need to know two things:

  1. What is the full (absolute) URL with which you open the HTML page? Check browser address bar.
  2. What is the full (absolute) URL with which you can open the CSS file individually in your browser?

Once you know both, you can do the math to get the right relative path for use in link tag.

BalusC
+1  A: 

It's either the wrong content-type header as jensgram suggests, or the relative path you are giving (css/...) is wrong because the page itself is in a different folder.

Install Firebug and switch to the "net" tab. It will show you if the files failed to load due to a wrong URL.

Pekka
hmm, it says "304 Not Modified" for css files. at Firebug Net tab
artmania
Hm. That means they get definitely loaded. Then go to the Firefox error console and have it show all messages. If the CSS files' content-type header is wrong (usually text/html instead of text/css), it will say so there. (This can probably be done somewhere in firebug as well but I don't know where.)
Pekka