# Solved: CSS Not Rendering



## pcpro17 (Oct 9, 2006)

Hello. The CSS on a site I'm developing (http://test.livelycaking.com) is not rendered by the Firefox, Netscape, and Flock web browsers. However, it is rendered by the Internet Explorer, Opera, and Avant web browsers.

Any thoughts?


----------



## Eriksrocks (Aug 7, 2005)

Not rendering for me on your site, although if I download the files and view them locally, it renders just fine. I have a feeling this is some odd file corruption business. Try reuploading both the HTML page and the CSS file. 

Also, if that doesn't work, do you have anything weird in your .htaccess?


----------



## pcpro17 (Oct 9, 2006)

Hi Erik. I tried deleting the entire site from the server and re-uploading it with the same results. I also tried running dos2unix on all the files from the shell command with no results.

I don't think there is anything weird in my .htaccess file:


```
# Prevents directory contents from being displayed on web browsers if an index file does not exist.
Options -Indexes

# Prevents direct hot-linking of images from other domains.
RewriteEngine On
RewriteCond %{HTTP_REFERER} !^http://(.+\.)?test.livelycaking\.com/ [NC]
RewriteCond %{HTTP_REFERER} !^$
RewriteRule .*\.(jpe?g|gif|bmp|png)$ - [F]

# Allows PHP scripting in CSS files.
AddType application/x-httpd-php .css [NC]

# If the page requested (%{REQUEST_URI}) has stats or failed_auth.html in it, redirect to the root of the domain.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_URI} ^/(stats|failed_auth\.html)/?(.*)$ [NC]
RewriteRule ^.*$ - [L]
</IfModule> 

# This is telling Apache (the webserver) to use the php.cgi and php.ini in ~/livelycaking.com/cgi-bin.
Options +ExecCGI
Action php-cgi /cgi-bin/php.cgi
AddHandler php-cgi .php

# Blocks access to sourcecode files and file integrity checksum files (MANIFEST).
<Files *.inc>
Deny From All
</Files>
<Files *.class>
Deny From All
</Files>
<Files MANIFEST>
Deny From All
</Files>
```


----------



## Eriksrocks (Aug 7, 2005)

Just try renaming your .htaccess to something like old.htaccess to take it out of the equation. This part especially catches my eye:


```
# Allows PHP scripting in CSS files.
AddType application/x-httpd-php .css [NC]
```
I'm not sure exactly what effect, if any, that would have on Firefox being able to render the CSS but just rename your .htaccess to make sure that isn't the problem.


----------



## lavazza (May 15, 2006)

Seeing the leading slash before the css filename, I suspect that it's a referencing issue

How about trying absolute referencing

OR

removing the slash


----------



## MMJ (Oct 15, 2006)

The problem is the line that Erik pointed out.

What that line does is compile .css files as if they were .php files. And this is sending a mime type of text/html which is preventing the browser from reading it properly.

I recommend removing it but if you want to use php in your style sheets than add this to the *very* beginning of the style cheat:


```
<?php
header('Content-type: text/css');
?>
```


----------



## tomdkat (May 6, 2006)

Great catch Erik and MMJ! :up:

Now, this seems to affect Gecko-based browsers only. Opera renders (and centers) the page just fine, as does IE7. Does this mean Opera and IE7 are ignoring the MIME type being sent?

Peace...


----------



## pcpro17 (Oct 9, 2006)

Thanks Erik & MMJ! That seemed to fix the problem. I'm not using PHP in CSS on this site, so after commenting out that line things started working as expected.


----------



## Eriksrocks (Aug 7, 2005)

tomdkat said:


> Great catch Erik and MMJ! :up:
> 
> Now, this seems to affect Gecko-based browsers only. Opera renders (and centers) the page just fine, as does IE7. Does this mean Opera and IE7 are ignoring the MIME type being sent?
> 
> Peace...


Well, it was MMJ who figured out the MIME type problem. :up:

But yes, it means that IE and Opera are ignoring the MIME type, or they simply don't care what the MIME type is as long as it contains valid CSS. You could probably send a CSS file with an _image/jpeg_ MIME type and they wouldn't care. It doesn't surprise we with IE rolleyes, but I would have thought that Opera would have behaved correctly.


----------



## MMJ (Oct 15, 2006)

Opera does seem to emulate alot of bad IE behavior.

document.all is a big one.


----------

