Fix "Refused to apply style … MIME type ('text/html') is not a supported stylesheet MIME type"
Refused to apply style from 'https://example.com/css/style.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
- Refused to apply style from 'http://localhost:3000/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
- Refused to apply style from 'https://example.com/blog/css/app.css' because its MIME type ('text/plain') is not a supported stylesheet MIME type, and strict MIME checking is enabled.
- The stylesheet https://example.com/css/style.css was not loaded because its MIME type, “text/html”, is not “text/css”.
- Did not parse stylesheet at 'https://example.com/css/style.css' because non CSS MIME types are not allowed in strict mode.
The browser requested your CSS file but received an HTML page, almost always a 404 page or a SPA home page returned instead of a missing file. Open the CSS URL in a tab: fix the path (often a relative path to make absolute with /) or make the server send the file with Content-Type: text/css.
What this error means
A stylesheet is only applied if the server sends it with the text/css MIME type. When the response comes as text/html, Chrome refuses to interpret it, especially if the server sends X-Content-Type-Options: nosniff, which is standard today. The announced type is almost never the real problem: it reveals that the server did not find the file and replied with an HTML page (404 error, login page, or index.html returned by a single-page app fallback rule). More rarely, the file exists but the server does not know the .css extension.
Common causes
- Relative path:
href="css/style.css"on the/blog/articlepage becomes/blog/css/style.css, which does not exist. - File missing from the deployment:
dist/orpublic/build/folder not uploaded, build not run, wrong case (Style.cssvsstyle.csson a Linux server). - SPA fallback rule or catch-all route that returns
index.htmlfor every URL, including missing static files. - Static folder misconfigured:
express.staticmounted on the wrong folder or after the*route, orinclude mime.typesmissing from the nginx configuration. - Link to an uncompiled file: a
<link>pointing to a.scssfile or a Tailwind source file instead of the generated CSS.
Step-by-step fix
-
See what the server really returns
Open the CSS URL quoted in the error in a new tab, or query it with curl. An HTML page or a 404 code confirms a path or missing-file problem.
curl -sI https://example.com/css/style.css | grep -iE "^HTTP|content-type" -
Use an absolute path
Start the path with
/so it resolves from the site root, whatever the page. In Laravel, useasset()or@vite.<!-- wrong on /blog/article --> <link rel="stylesheet" href="css/style.css"> <!-- right --> <link rel="stylesheet" href="/css/style.css"> -
Check the file is really deployed
Run the build and check that the file exists at the expected path on the server, with the right case.
npm run build ls -la dist/assets/ public/build/assets/ 2>/dev/null -
Express: serve static files before the fallback
Mount
express.staticon the right folder and before the route that returnsindex.html. With Express 5, the catch-all route is written/{*splat}.import express from 'express'; import path from 'node:path'; const app = express(); const dist = path.resolve('dist'); app.use(express.static(dist)); app.get('/{*splat}', (req, res) => res.sendFile(path.join(dist, 'index.html'))); -
nginx: MIME types and 404 on static files
Check that
mime.typesis included and that a missing CSS or JS file returns a real 404 instead ofindex.html. Test, then reload nginx.http { include /etc/nginx/mime.types; server { root /var/www/app/dist; location ~* \.(?:css|js|mjs|map)$ { try_files $uri =404; } location / { try_files $uri $uri/ /index.html; } } }
Did this fix work for you?
Confirm it in one click: it will rise for the next developers stuck on the same error.
Keep it from coming back
- Let your build tool or framework generate the
<link>tags instead of writing them by hand. - Configure the server so missing static files return a 404: the error becomes obvious in the Network tab.
- Name your files in lowercase to avoid surprises between macOS/Windows (case-insensitive) and Linux.
Frequently asked questions
Should I remove the X-Content-Type-Options: nosniff header?
No. It protects against disguised files being executed. The real problem is that the server returns HTML instead of CSS: fix the path or the MIME type.
CSS works on the home page but not on other pages, why?
Your link is relative. On /, css/style.css points to the right place; on /blog/article, it points to /blog/css/style.css. Add a leading /.
What if the announced type is text/plain?
The file is found but the server does not know the extension: add include mime.types (nginx), AddType text/css .css (Apache) or check your host or S3 bucket configuration.
Useful tools for this error
Error finder
Paste an error message or a log: the tool recognises the error and opens the right fix.
HTTP status codes
All the common HTTP codes (401, 403, 404, 419, 429, 500, 502…): meaning, causes and what to do.
cURL converter
Paste a cURL command (DevTools “Copy as cURL”): get the fetch, axios, Node, PHP (Laravel Http or curl) or Python requests code.
More Web, HTML & CSS errors
- Fix "Mixed Content: … requested an insecure resource" (HTTPS mixed content)
- Fix "Failed to load module script: Expected a JavaScript module script … MIME type of text/html" (Vite, SPA)
- Fix "Refused to execute inline script because it violates the following Content Security Policy directive"
- Fix ERR_TOO_MANY_REDIRECTS "redirected you too many times" (redirect loop)
- Fix "Your connection is not private" NET::ERR_CERT_DATE_INVALID and ERR_CERT_AUTHORITY_INVALID
- Fix "ResizeObserver loop completed with undelivered notifications"
- Fix net::ERR_BLOCKED_BY_CLIENT (ad blocker, analytics, "ads" files)