43

I have a javascript application and when I run it on firefox I am getting the following erro on the console:

"The stylesheet was not loaded because its MIME type, "text/html" is not "text/css".

DumbStuck!!

EDIT: Note that it tells that "The stylesheet ABCD..." But ABCD is actually an HTML file.

Edit (ANSWER) : Actually I had wrongly put href="", and hence the html file was refenecing itself as the CSS. Mozilla had the similar bug once, and it is from there I got the answer. But everyone's else answers helped me too. Thanks.

Suraj Chandran
  • 24,433
  • 12
  • 63
  • 94
  • 2
    Can you supply some example markup? – belugabob Feb 03 '10 at 08:16
  • 1
    I guess you include `ABCD` the wrong way... – Felix Kling Feb 03 '10 at 08:20
  • Accepting this is closed, and old - however, if it helps someone else. I've just had the exact same error message in console, but discovered the url was broken. The error message was not identifying the actual issue. (For clarity, my css file had the correct type attribute and suffix: .css, not .html as indicated in some of these answers). – GLCoder May 09 '21 at 18:34

7 Answers7

24

In the head section of your html document:

<link rel="stylesheet" type="text/css" href="/path/to/ABCD.css">

Your css file should be css only and not contain any markup.

tfentonz
  • 524
  • 2
  • 7
17

Actually I had wrongly put href="", and hence the html file was referencing itself as the CSS. Mozilla had the similar bug once, and I got the answer from there.

mruanova
  • 6,351
  • 6
  • 37
  • 55
Suraj Chandran
  • 24,433
  • 12
  • 63
  • 94
10

This is more likely an issue at your server side. you request style sheet page "Styles/Site.css" from the server of type "text/css", but your server might be responding to this request with "test/html". I had this issue when my server was running in python and it was replying to requested css files with header text/html (as that of my index.html file). I re-arranged my server code and assigned the correct headers to its corresponding pages and my issue got resolved.

Anum Sheraz
  • 2,383
  • 1
  • 29
  • 54
2

You are trying to use it as a CSS file, probably by using

<link rel=stylesheet href=ABCD.html>

or

<style>
@import url("ABCD.html");
</style>
Ms2ger
  • 15,596
  • 6
  • 36
  • 35
1

This is what did it for me in .htaccess (it could be that you had a directive making all files load as MIME type text/html):

In .htaccess

AddType text/css .css
Areeb Soo Yasir
  • 598
  • 7
  • 8
1

In Ubuntu In the conf file: /etc/apache2/sites-enabled/your-file.conf

change

AddHandler application/x-httpd-php .js .xml .htc .css

to:

AddHandler application/x-httpd-php .js .xml .htc
JC Lopez
  • 243
  • 1
  • 2
  • 12
0

Review any .htaccess. Maybe, a .htaccess rule is interfering with the right output. Try browsing your CSS resource directly in your address bar, it must be presented in text format.

christian
  • 538
  • 5
  • 8