I have a CSS file linked with my HTML file.
The CSS doesn't load when loading the HTML file through live-server.
The CSS works fine when opening the HTML file directly through the browser.
I have my CSS file outside the directory where the HTML file is.
When having live-server in my npm script, starting it with npm start
, without any argument, it just shows all files of my workspace and the CSS works if I click on the directory where the main index.html
is.
But if I add the path as an argument in the npm script, it only loads the HTML file without any CSS.
The link in the HTML file, index.html :
<link rel='stylesheet' type='text/css' href='../styles.css'>
In package.json :
"start": "live-server home"
The above doesn't load the CSS. Only
"start": "live-server"
works, which shows the working directory in the browser.
– I click the home directory and then the HTML file loads with the CSS.
When typing npm start from the terminal, my HTML file loads fine in my browser, but for some reason, the linked CSS file isn't loaded.
The CSS link should be fine, since it works correctly when opening directly from the browser.
Does the CSS file need to be in the same directory?