Link a .CSS File in Another Folder

Link CSS from another folder?

If your current folder is /current/folder/location/index.html, and your .css file is in /current/second/folder/style.css, then use this as an example:

<link rel="stylesheet" type="text/css" href="../../second/folder/style.css">

or alternatively:

<link rel="stylesheet" type="text/css" href="/current/second/folder/style.css">

However, if the second file is in `/current/folder/second/style.css, then use:

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

Link a .css file in another folder

I dont get it clearly, do you want to link an external css as the structure of files you defined above? If yes then just use the link tag :

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

so basically for files that are under your website folder (folder containing your index) you directly call it. For each successive folder use the "/" for example in your case :

    <link rel="stylesheet" type="text/css" href="Fonts/Font1/file name">
<link rel="stylesheet" type="text/css" href="Fonts/Font2/file name">

How do I link a CSS stylesheet from another folder below in the directory?

In your case:

<link rel="stylesheet" style="text/css" href="../CSS/file.css">

More cases:

You can go up directories with ../

So for each ../ you will go up 1 directory


If you are in /public/files/ you can do

<link rel="stylesheet" style="text/css" href="../CSS/file.css">

to get into /public/CSS/


If you need to acces the root it could be:

<link rel="stylesheet" style="text/css" href="../../file.css">

to get into /


You can also link it from the current script directory:

<link rel="stylesheet" style="text/css" href="./CSS/file.css">

If you are in /public/files/ it would be /public/files/CSS/


And last from root to the directory:

<link rel="stylesheet" style="text/css" href="/public/CSS/file.css">

It would be /public/CSS/ and your file

Linking CSS File with HTML Document In Different Directories On my Windows

You should go back one directory back by ../. This way go to parent folder of these two files. Then start to go into css file's directory.

href="../styles/style1.css"

Cannot link index.html file to style.css file in another folder

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.

How to Link to a Stylesheet in a subfolder

Your path - href="../stylesheets/stylesheet.css" is basically doing the opposite of what you want.It's not going one folder further as you wish.

To accomplish what you want, you are going to have this path:

href="stylesheets/stylesheet.css"

Here you can read more about File Paths.



Related Topics



Leave a reply



Submit