Linking a CSS file to an HTML document in the same directory on my hard drive (Windows)

I am using Windows (7) trying to create a standalone html page that needs to link to a separate CSS file located in the same directory. I tried to use

<link rel="stylesheet" type="text/css" href="/styles.css"  />

      

but no luck.

And also want to import another css file named styles2.css in style.css. However, I haven't checked it, but @import "style2.css";

it can't put on style.css either. I can use a fixed link, for example C:\Users\ELITEBOOK\Desktop\offline\style.css

, but it won't work if I move the folder somewhere else from my desktop. Any help? I mean any code that calls / adds a link to a folder?

+3


source to share


2 answers


Use <link rel="stylesheet" type="text/css" href="./styles.css" />

instead. Note: href="/styles.css"

changed to href="./styles.css"

which is the current directory of your script.



+5


source


try this one, it worked for me.



 <link rel="stylesheet" href="./main.css">

      

0


source







All Articles