Search code examples
htmlcssvisual-studio-codeliveserver

Cant get my CSS to be viewed in live server


I've started to get into web development and decided to just do projects on my own instead of odin project and freecodecamp but ive ran into a weird simnmple issue that i cannot get my css to be viewed in the live server extension of VSC.

The error in the console is "Refused to apply style from 'http://127.0.0.1:5500/styles.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled."

I'm sure its just some stupid thing but im pretty sure everything is linked correctly, but I'm not to sure.

ive tried using other ways to connect my css to the html but to no avail.


Solution

  • Based on experience, this problem is often caused by incorrect paths.

    I suggest taking a look at the CSS file path first, especially the href attribute of the link tag.

    just like

    <link rel="stylesheet" href="../test.css" />
    

    If it cannot be solved, you can post your file structure and code for further analysis.