Can't Load External Css When In Localhost
I'm working on a project using arduino, node.js and socket.io. I am running it in localhost, however my external stylesheet wont load. The error seems to be saying it cant get my c
Solution 1:
Try this instead:
<link rel="stylesheet"type="text/css" href="./css/main.css">
notice the ./
in front of the href
otherwise include full path name:
<link rel="stylesheet"type="text/css" href="http://localhost:1337/css/main.css">
Solution 2:
this is what i have tried and it is working for me
<link href="./main.css" rel="stylesheet"type="text/css" />
thanks
Solution 3:
The relative path kicks off from your html path so
<link rel="stylesheet"type="text/css" href="main.css">
should work (as your main.css is outside of the css folder). Alternatively, you could put the main.css file on the css folder and reference it with "css/main.css"
Solution 4:
To serve static files such as images, CSS files, and JavaScript files, use the express.static built-in middleware function in Express.
The function signature is: app.use(express.static(__dirname));
Then you can include like bellow
<html><linkrel="stylesheet"href="/css/style.css"></html>
Solution 5:
I was facing same problem as you are facing but i tired below code and it works.
body{
background-color: yellow;
}
h1{
color: red;
}
p{
color:green;
}
<html><head><linkhref="./external.css"rel="stylesheet"type="text/css" /></head><body><h1>This is my First page to test CSS</h1><p>The main motive to making this html file is to test my CSS skill.....</p></body></html>
Thanks, hope it will help you......
Post a Comment for "Can't Load External Css When In Localhost"