does a server have to announce that style sheets are "text/css"?

Drew Taylor drew at drewtaylor.com
Fri Apr 11 13:42:19 EDT 2003


Seth Gordon wrote:
> I've been making our family home page (http://ropine.com/)
> standards-compliant, and encountered an odd "feature" of Mozilla and
> Galeon.  If an HTML page has a DOCTYPE declaration (i.e., the browser
> renders it in "strict" rather than "quirks" mode) and a link to a
> stylesheet, but the server does not declare that stylesheet to be
> "Content-type: text/css", then the browser will ignore the stylesheet.
> 
> Is this actually following the standard?  The CSS1 spec says nothing
> about this, and in the CSS2 spec, "The text/css content type" (3.4) is
> not part of the "Conformance" section (3.2).  And it seems odd for the
> browser to be so picky about the Content-type header; unlike a situation
> where the browser is sent to a random URI and has to decide whether it's
> HTML or plain text or what, when a browser is told to fetch a CSS
> document, it *knows* it's fetching a CSS document.

I don't know if it's part of the "standard", but mozilla and IE (IIRC) 
require the correct mime type for stylesheets when running in strict 
mode. I ran into this myself recently when I was updating some internal 
apps to be 4.01 compliant.

If you're using mozilla, open the javascript console and load 2 pages: 
the first with a linked stylesheet not of type "text/css" and the second 
with the correct mime type. You'll notice the warnings when in quirks 
mode. It's just the way it is. And IMHO it's a good thing since we're 
supposed to be running in compliance with the standards.

It's easy to fix as well: just make sure the default handler is run for 
your .css files. Assuming apache:

<Location /css>
   SetHandler default-handler
</Location>





More information about the Discuss mailing list