Reputation: 33
I spent the last hour figuring out why my style sheet is working.
I tried every possible way, but none of it works.
It just shows error 404 when I check it in the developer mode of my browser.
I tried
<link href="style.css" type="text/css" rel="stylesheet" />
<link href="./style.css" type="text/css" rel="stylesheet" />
<link href="../style.css" type="text/css" rel="stylesheet" />
<link href=".../style.css" type="text/css" rel="stylesheet" />
I also placed the CSS file in the same file as my header.php file.
Upvotes: 0
Views: 414
Reputation: 1
You are using many link tags to integrate the CSS file in your HTML file. You should use one tag and it would be a relative path like the following <link rel="stylesheet" href="/css/style.css">
Upvotes: 0
Reputation: 52
../ is meant to go back a folder, so if my folder layout is
Root
css
includes
I have to go down a folder and enter the css folder like:
<link rel="stylesheet" href="../css/style.css">
Upvotes: 1
Reputation: 9884
The path to the css file is a relative path from the file that's called from the browser, and that's most likely not header.php
.
If you start the path with a /
it's considered relative to the webroot, so you probably want /css/style.css
. Note that you cannot go up (using ../
) from the webroot.
Upvotes: 1