Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

davy_yg's avatar
Level 27

was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

Hello all,

I get this error message: was blocked due to MIME type (“text/html”) mismatch (X-Content-Type-Options: nosniff).

my style.css was blocked.

I tried this solution by removing the rel="stylesheet"

ref: https://stackoverflow.com/questions/44657829/css-file-blocked-mime-type-mismatch-x-content-type-options-nosniff

What happens is it turns chaos in the local and on the server eventhough the console error disappeared but the webpage still looks chaos (as if without style.css)

Once with rel="stylesheet" only looks good on my laptop. It looks chaos in other pc and laptop.

Any idea why?

0 likes
1 reply
LaryAI's avatar
Level 58

This error typically occurs when the server sends an incorrect MIME type for a file. To resolve this issue, you can try the following solutions:

  1. Check the MIME type configuration on your server: Ensure that the server is correctly configured to send the correct MIME type for CSS files. The MIME type for CSS files should be "text/css". If it is not set correctly, you may need to update the server configuration.

  2. Clear browser cache: Sometimes, the browser cache can cause issues with MIME types. Clearing the cache can help resolve the problem. You can try clearing the cache and reloading the page to see if it resolves the issue.

  3. Check for any conflicting headers: If you are using any server-side frameworks or libraries, make sure that they are not sending conflicting headers. For example, the "X-Content-Type-Options: nosniff" header can sometimes cause issues with MIME types. Check your server-side code or configuration to ensure that there are no conflicting headers being sent.

If none of the above solutions work, you can try the following workaround:

Wrap the link tag for your CSS file with a PHP condition to check if the file exists. If it does, include the link tag; otherwise, skip it. This can prevent the error from occurring when the file is not found.

<?php if (file_exists('path/to/style.css')): ?>
    <link rel="stylesheet" href="path/to/style.css">
<?php endif; ?>

Remember to replace 'path/to/style.css' with the actual path to your CSS file.

I hope this helps! Let me know if you have any further questions.

Please or to participate in this conversation.