'How do I link a CSS stylesheet from another folder below in the directory? [duplicate]
This is what I'm trying to link into my HTML and it's not working I tried taking off the two periods and that doesn't work either.
<link rel="stylesheet" style="text/css" href="..CSS/file.css">
Solution 1:[1]
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
Solution 2:[2]
<link rel="stylesheet" style="text/css" href="../CSS/file.css">
Solution 3:[3]
if you want to import css files to another css file use below syntax:
@import "url or path to file";
Solution 4:[4]
<link rel="stylesheet" style="text/css" href="../../CSS/file.css">
Or use full url :
<link rel="stylesheet" style="text/css" href="://www.yoursite.com/file.css">
In full url, :// is instead specify http:// or https://
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Marcin Restel |
Solution 3 | Abolfazl Miadian |
Solution 4 | btc4cash |