htmlcsssimplehttpservernpm-live-server

Cannot link index.html file to style.css file in another folder


I'm trying to link my style.css file to my index.html file. Both files are located in separate folders.

Folder structure:

/parent

Codes that I have tried using:

<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="./css/style.css">
<link rel="stylesheet" type="text/css" href="/css/style.css">
<link rel="stylesheet" type="text/css" href="css/style.css">

The same error I keep getting in the terminal:

GET /css/style.css 404 1.542 ms - 152

I'm using VS Code with live-server.

Note: When I put my index.html file outside src folder in the parent folder. The path href="css/style.css" works.


Solution

  • Start live-server in the Root /parent, then navigate to /src/index.html. If you start in the directory containing index.html you can Not go upwards.