Occasionally you find the need throw some dynamic information into your CSS file. This usually entails giving your CSS file an extension that will force it to be interpreted by your scripting language processor (i.e. style.css.php or style.css.cfm).

Then, just like a static css file, we load it:

<style type="text/css"><!-- @import url('/src/css/style.css.cfm'); --></style>

Only to find that all browsers except Internet Explorer don't render the CSS within the file.

The reason is simple, Firefox and the Webkit browsers require that the CSS file bear a mime-type of text/css.

If ColdFusion is your language, dropping a <cfcontent> tag at the top of the CSS file will resolve this issue:

<cfcontent type="text/css">

PHP developers will have equally easy solution:

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


Leave a Reply

Your email address will not be published. Required fields are marked *