Why won't my HTML image load? It just shows a blue box that represents an image?
Here is my directory structure
And here is my code
<body>
<img src="ImageFolder/download.jpg">
<h1> Welcome to my smelly fish</h1>
</body>
Here are the errors from chrome
Refused to apply style from
'http://localhost:3000/css/main.css' because its MIME
type ('text/html') is not a supported stylesheet MIME
type, and strict MIME checking is enabled.
download.jpg:1 Failed to load resource: the server
responded with a status of 404 (Not Found)
localhost/:1 Refused to apply style from '
http://localhost:3000/css/main.css' because its MIME t
ype ('text/html') is not a supported stylesheet MIME
type, and strict MIME checking is enabled.
Related
I have read numerous questions with a similar trouble but they usually were caused by a server misconfiguration. I use unpkg.com service so I assume it is configured correctly.
My HTML5 static page contains:
<link rel="stylesheet" type="text/css" href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https://unpkg.com/bootstrap-vue#latest/dist/bootstrap-vue.css">
My app is written in Vue but that code is still present in generated file.
Chrome shows the following warnings:
Resource interpreted as Stylesheet but transferred with MIME type text/plain: "https://unpkg.com/bootstrap/dist/css/bootstrap.min.css".
Here is the response caught by Network tab in Developer tools. Content type is text/plain
And the second redirected request with text/css:
When I enter this URL in Chrome location bar, I receive 302 status code first having the text/plain mime type first and the second fetch is expected text/css.
Is this sort of Chrome bug that it complains about the content type of request to be redirected? Or is it unpkg.com error? Is there a way to get rid off these errors (I can bundle the file in my Vue app but I want to minimize the transfers).
You can try it live here: https://beta.mezinamiridici.cz/ankety/jizda-v-tesnem-zavesu-za-kamionem
I was running own website on localhost, with the server showing everything correct, Chrome gives me some errors:
Refused to apply style from 'http://example.com' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
Is there any way to skip it or disable it?
You don't have to disable MIME checking. See an explanation.
The problem is probably, that your stylesheet file is not accessible with the URL you defined in the link element. Maybe just a typing error. Try to click on the link in the error message and see if it can be loaded.
Check your stylesheet references in your code
<link rel="stylesheet" type="text/css" href="/styles/styles.css" />
This is more out of curiosity than anything, but is it possible to save a stylesheet on Pastebin and load it in an HTML document? I tried to do it the way you'd normally link a stylesheet, but it didn't work. Here's the test code I used:
<html>
<head>
<title>Test</title>
<link rel="stylesheet" type="text/css"
href="http://pastebin.com/0dY5eBga" />
</head>
<body>
<p>This is a test. Will it work? Probably not.</p>
</body>
</html>
The code I'm trying to use is saved at http://pastebin.com/0dY5eBga.
You cannot import stylesheets from pastebin in this way, even using the raw url, because the pastebin server sets a Content-Type header of text/plain on the HTTP response. This will prevent the file from being properly interpreted as a CSS stylesheet.
For instance, Chrome will give the following error:
Resource interpreted as Script but transferred with MIME type text/plain
And then it will refuse to apply your styles.
Please see the following MDN articles for details about incorrect MIME types on CSS files - many browsers block resources with incorrect MIME types:
Incorrect MIME Type for CSS Files
Configuring Server MIME Types
Here is a live example of CSS not working when linked from Pastebin, because the server does not send it with the text/css MIME type:
<link href="http://pastebin.com/raw.php?i=0dY5eBga" rel="stylesheet"/>
<p>This text is not red.</p>
The Error I get on my website in IE console is
SEC7113: CSS was ignored due to mime type mismatch
Seems the CSS is not getting loaded at all.
I have researched a lot.There are quite a few questions on this around the web, but there is no conclusive fix.
Microsoft official site says to add type="text/css" attribute to the link tag, but in my case, I have already added it, in vain.
Is there any fix to this?
You need to set the Content-Type http header to text/css. With htaccess:
AddType text/css css
Here is the problem, try to load a css file from a folder and get the console error: "Resource interpreted as Stylesheet but transferred with MIME type text/html". Try to fix it by adding .htaccess file (in the root/in same folder as css) with "AddType text/css .css" in it, but it is completly ignored.
How can it be fix?
(Don't know if matters but I'm in windows 8.1 and WAMP)
Appreciate any feedback.
Try this:
<FilesMatch "(\.css)$">
AddType text/css .css
Header set Content-Type text/css
</FilesMatch>
But you really shouldn't have to. text/html is normal.
Because of a security issue it is not enough to set style sheet "rel" tag type property to text/css, you should set content type in http headers(content-type:text/css), it seems you use Apache but in case another person have this problem in IIS and see this page: go to control panel -> programs and features -> turn windows features on or off -> internet information services -> world wide web services -> common http features -> static content, enable this option and restart your IIS.