0

In the head of my html page I have:

<link media="screen" href="tabs.css.php?tabs=374,375,376,377,378,379,381,380" type="text/css" rel="stylesheet">

The CSS is dynamically created based on the tabs parameter.

This works in IE9, but not in Chrome or Firefox. However, when I tried saving the generated CSS as "tabs.css" and pointing Chrome to that, it worked. That doesn't help me much though because I need the style to be dynamically generated.

How can I get Firefox and Chrome to recognise the stylesheet?

1
  • Just out of curiosity, why would you want to do this? Commented Feb 28, 2013 at 5:32

1 Answer 1

2

I fixed this issue by adding this line to the top (before any output is sent, even a blank line) of my PHP file which generates the stylesheet:

header('Content-type: text/css');

It seems that when the file has a .css extension it is correctly recognised by Firefox and Chrome as CSS, but not when it's got a .php extension. This other answer has some links that might be useful to you if you want to learn more.

Sign up to request clarification or add additional context in comments.

1 Comment

Well Setting correct content type is always be must when you output non-html content from a php file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.