I've been pulling my hair out over this one.
<link rel="stylesheet" href="/icons/style.css">
<link rel="stylesheet" href="/css/custom.css">
the custom.css ref works fine, the one in the icons dir just returns a "The requested URL was not found on this server.", it will work however if:
<link rel="stylesheet" href="/css/icons/style.css">
... I drop the icons dir into the CSS dir! So, my local WAMP server install is set to only read CSS files from a dir named CSS?
It's one of those things that seems so random and is sucking so much time and energy from me.
Cheers.
this is mean the dir is incorrect so you need to type the correct one
if the file path points to a file in the icons folder located in the folder one level up from the current folder, then your code should be like this
<link rel="stylesheet" href="../icons/style.css">
if this solution not working for you try one of those
https://www.w3schools.com/html/html_filepaths.asp
Answer is, Apache reserves or configs any folder named 'icons' in some special way... https://electrictoolbox.com/apache-icons-directory/
Related
i have started to add include files like header, nav, footer.php to my index.php in my root directory, i got a admin folder with another index.php, with the same include files except it is using "../" in its target path to go back one before accessing the includes file, what happens is it works except for the css files... i lose my styling, but on my root index.php if i go back to that, the styling is working.
Any idea why this is happening?
my css code is:
<link rel="stylesheet" href="css/main.css">
Use an absolute path in your link tag
<link rel="stylesheet" href="/css/main.css" />
As kindly pointed out by John, this is not an absolute path and in all honesty I have no idea what to call it (root relative?). What I do know is that it is relative to the root of the site and not the current folder on the server.
The syntax you're using is relative path.
Use either this to fix the relative path:
<link rel="stylesheet" href="../css/main.css">
Or make it absolute if your css directory is in the web docroot:
<link rel="stylesheet" href="/css/main.css">
if css folder is outside of your admin folder it should be ../css/main.css, right?
For a better management, I'll use an abolute path with full url
<link rel="stylesheet" href="{$html_css}/main.css" />
I am trying to include css file with php so that i have one same path through my sub folders and files as well. This is my code
<link rel="stylesheet" href="<?=ROOT;?>CustomStyles/MyStyles.css">
I have constant root set up before in this way:
define('ROOT', $_SERVER['DOCUMENT_ROOT']);
However this does not work because the result of the link is that after ROOT constant there is the web address of my server.
Can anyone help me please?
Thank you very much.
Place your css file in public directory. Example assets/. And link
<link rel="stylesheet" href="//your.site/assets/MyStyles.css">
I've got a login form with css. When I open it from my whampserver (localhost) it doesn't display the css, but when I save it on my desktop and open it from their it does.
Does anyone have an idea why this happens.
pls don't down vote because it's obvious.
You're using a local absolute path to your CSS file ("C:\Users\marij_000....").
Once you'll deploy your site to a different server it won't be able to access your local computer , thus, the CSS link will be broken.
Best Practice advice. Add a "css" folder to your project and place all the CSS files in that folder, then use a relative path to your files. For example:
<link rel="stylesheet" type="text/css" href="/css/main.css">
the first "/" state that the server will start the path from the project's root folder.
I have this line in the head of a php.page
<link href="css/header.css" rel="stylesheet" type="text/css" />
LiveView in dw - shows everything formated well (css works)
f12 (using wamp) - also works well.
Now, I changed some line in header.css (for example cell padding) - then File - Save All
Live View still works - shows the changes correctly
But f12 (wamp) does not show the changes.
If I move header.css file from css folder to the root folder (and change the link) - wamp works well
But I want to have my css files in css folder, not in the root folder.
What is the solution, please?
Clear your browser cache. That should fix the issue.
You can do it automatically if you use ctrl+F5 in your browser.
Find your web root path and append it to the css file
Example.
<link href="<?php echo $webroot?>/yourfolder/css/header.css" rel="stylesheet" type="text/css" />
You could use
<link href="css/header.css<?php echo '?rnd_'.urlencode(time()).'='.urlencode(rand()); ?>" rel="stylesheet" type="text/css" />
For debugging purposes this is ideal, because it appends a random query string to the CSS-file-request in order not to be cached.
I'm trying to set up my site in Dreamweaver CS5 to work with my local server, and I'm having issues with document relative links.
I've got a structure on my HD like this
website
_Common
header.php
_css
twoColFixRtHdr.css
index.php
and the same structure mirrored on my local WAMP server, except on the local server the site is in a subfolder, so it's something like www/website/
The problem is this line inside header.php
<link href="../_css/twoColFixRtHdr.css" rel="stylesheet" type="text/css" />
That looks correct to me pathwise, but on the local server it cannot find that css file from the header.php
If I change it to
<link href="/website/_css/twoColFixRtHdr.css" rel="stylesheet" type="text/css" />
or
<link href="_css/twoColFixRtHdr.css" rel="stylesheet" type="text/css" />
It works fine, but I want to use document relative links if I can, any ideas?
This sounds clear to me, since I'm sure that you include the header file in the index.php file. So the path for the css files is set relatively to the index.php.
you may achieve it by several ways.
one of them: you can setup a VirtualHost (in httpd.conf) and point your subfolder as root folder for host.
If header.php is being included in index.php, the relative link ../_css/ in header.php won't work because index.php is at the same level as _css.
For all intents and purposes, once it's been included in index.php, to the browser, the content in header.php is now simply part of index.php, so all paths need to be relative to index.php.
Ie:
index.php
/my_include_folder
- header.php
/_css
- style.css
Once I add <?php include('my_include_folder/header.php); ?> to index.php, the links to css files, js, and hyperlinks in header.php should be relative to index.php.
Hopefully that makes sense.