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.

2
  • 1
    Try ../../css/style.css Commented Aug 22, 2019 at 22:24
  • @Albeis Same error. Commented Aug 22, 2019 at 22:30

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

-1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.