0

When I try to open my html file directly by clicking on it, it's not loading the CSS file or images but when I open it with VS code live server it working fine. The images and stylesheet is on different files

here is the code : <link rel="stylesheet" href="/CSS files/stylesheet.css" type="text/css"> <meta charset="UTF-8">

1
  • When you directly click on the html file, go to inspect page and check the link tag you provided. If you hover over the href attribute it will show what file location it is pointing to. I think in your case it might be pointing to the wrong location. Commented Aug 9, 2023 at 15:00

1 Answer 1

0

Try this answer https://stackoverflow.com/a/16643104/22147483. The href attribute in your code appears to use an absolute path.

Edit.: Try adding a './' before the path to the file to use a relative path.

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

2 Comments

Link only answers should be updated to include the important/relevant information from the link (in case the link ever breaks in future)
@Harrison answers edited...

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.