I\'m working on a website that uses gulp
to compile and browser sync to keep the browser synchronised with my changes.
The gulp task compiles everything
I was working with the React.js
app and also had this error which led me here. This is what helped me. Instead of adding <link>
to the index.html
I added an import
to the component where I need to use this stylesheet:
import 'path/to/stylesheet.css';
The issue, I think, was with a CSS library starting with comments.
While in development, I do not minify files and I don't remove comments. This meant that the stylesheet started with some comments, causing it to be seen as something different from CSS.
Removing the library and putting it into a vendor file (which is ALWAYS minified without comments) solved the issue.
Again, I'm not 100% sure this is a fix, but it's still a win for me as it works as expected now.
I know it might be out of context but linking a non existed file might cause this issue as it happened to me before.
<!-- bootstrap grid -->
<link rel="stylesheet" href="./css/bootstrap-grid.css" />
If this file does not exist you will face that issue.
In most cases, this could be simply the CSS file path is wrong. So the web server returns status: 404
with some Not Found
content payload of html
type.
The browser follows this (wrong) path from <link rel="stylesheet" ...>
tag with the intention of applying CSS styles. But the returned content type contradicts so that it logs an error.
As mentioned solutions in this post, some of the solutions worked for me, but CSS does not apply on the page.
Simply, I just moved the "css" directory into the "Assest/" directory and everything works fine.
<link rel="stylesheet" type="text/css" href="assets/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="assets/css/site.css" >
This error can also come up when you're not referring to your CSS file properly.
For example, if your link tag is
<link rel="stylesheet" href="styles.css">
but your CSS file is named style.css
(without the second s) then there is a good chance that you will see this error.