Forum Moderators: not2easy

Message Too Old, No Replies

CSS Link Styles not working in Firefox

works in IE and validates

         

Visit Thailand

1:20 am on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am just getting into css and have already run into a couple of what I think should be simple problems. Just can't get my head around them.

The CSS validates, have searched on G, am using doctype: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

The width and max-width works in IE (using IE7) as do all the link attributes - hover etc.

In Firefox (latest) none of above works for me. I wondered whether it was because I also had a:link, hover etc in the body so the duplication between external style sheet and body was causing problems. However after I deleted the body attributes and it did not work either.

I have also just this second created a brand new blank page with one word in plane text and another with link and it works in IE and not Firefox.

Any ideas please?

encyclo

2:27 am on Feb 23, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is it the entire stylesheet which is non-functioning in Firefox, or just some of the rules?

If it is the entire stylesheet, then you may well have a server misconfiguration. In standards-compliance mode (triggered by your full doctype), Firefox is stricter in the way it handles CSS files. If your server is (mis)configured to serve .css files as

text/plain
instead of
text/css
then the stylesheet will not be loaded.

Open the CSS file directly in Firefox (so you will see the stylesheet itself displayed in the browser window), and then check the MIME type by pressing Ctrl+I (or right click and select Page Info). If "Type" is anything other than

text/css
then add the following to a document-root-level .htaccess file:

AddType text/css .css

If you are not running Apache or cannot use .htaccess, then contact the server administrator to fix the problem.

More info here:

  • When only Firefox is not applying an external CSS file [webmasterworld.com]
  • Visit Thailand

    3:07 am on Feb 23, 2007 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    Thank you encyclo. Checked what you suggested and have now fixed it and am truly happy to say all is working.

    I should have pehaps thought of the MIME type as I had the same problem some years back with xml/rss.

    Thanks.

    encyclo

    3:19 am on Feb 23, 2007 (gmt 0)

    WebmasterWorld Senior Member 10+ Year Member



    You're welcome. :) If your site is on a dedicated server then you should try to correct the misconfiguration in httpd.conf (or in IIS if you run Windows). If it is a shared or managed server, then you should get the server administrator to fix the problem server-wide. The .htaccess entry is really just a workaround for a poor server configuration.