1

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

Folder structure:

/parent

  • /src/index.html
  • /css/style.css

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.

efkah
  • 1,628
  • 16
  • 30
Shaze
  • 23
  • 5

2 Answers2

0

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.

efkah
  • 1,628
  • 16
  • 30
-1

Your href should look like this: href="style.css"