Mozilla Css Mime Type

From CSS Discuss

Jump to: navigation, search

Often, people new to CSS and/or Mozilla run into an issue, in which CSS is ignored when viewed from the production server, but works fine locally. This is usually caused by a misconfiguration of the server and is not a browser bug.

Servers tell the client what type of content the file contains (using the Content-Type header with a Mime Type as the value), some servers are misconfigured and return an incorrect Mime Type for CSS files (typically text/plain or application/x-pointplus) which should be sent with a text/css Mime Type .

Most browsers ignore the Content-type, trusting that any stylesheet will be CSS or using Content Sniff to guess what the file contains. Mozilla, however, when in Standards Rendering Mode does not, and correctly ignores stylesheets which the server claims are written in a style language the browser does not know about.

The solution is to have your server configured correctly.

Contents

Apache

Apache reads a "mime.types" file. Make sure it includes the line: text/css css

You can also use Apache configuration directives to set the Content-type. If the worst comes to the worst you may be able to use a .htaccess file (which applies to the directory it is in and all subdirectories) to set the configuration (the default Apache configuration disallows this, but many hosts turn it on to allow users some degree of configuration).

Add Type text/css .css

IIS

If you're the admin of IIS, you can configure files with the extension .css to map to text/css by going in to the site (or directory) properties, then HTTP Headers>File Types>New Type, .css, text/css.

If you're not the admin of IIS, ask your admin to configure the server to return CSS correctly. If they don't know what this means, tell them (from the description just above). Or find another host. They really should know this stuff.

If you are using IIS and your admin will not fix the configuration, you are out of luck. Time to look for another host, one that a) knows how to configure their server and b) responds to their paying customers.

The Type Attribute

Isn't that what the <link type="text/css" href=... rel=...> is for?

The type attribute contains advisory information. It says to expect text/css, this would allow a user agent to ignore the link if it is told to expect a language it doesn't understand. When the browser requests the style sheet it receives the HTTP header first, the HTTP header is authoritative.

Resources

Dev Edge "Incorrect mime type for CSS file"

Personal tools