I have an PHP file located here :
/public_html/folder1/folder2/index.php
and this file requires CSS file located here :
/public_html/folderX/folderY/css1.css
what is the correct path to access that CSS file should I put in the index.php? thanks.
Assuming that public_html
is your root:
<link rel="stylesheet" type="text/css" href="/folderX/folderY/css1.css" />
My personal advice is not to meddle with relative paths; they will only get you into trouble when you start moving your PHP scripts around; or worse, when your code gets included as part of another script and you have no way of knowing where that is.
The same thing could be said for references inside your CSS (images); it's not always immediately obvious that relative paths inside CSS files are taken from the location of that file as opposed to inline CSS, which uses the location of the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With