0

I can't seem to reference my styles in my css style sheet from my footer.php file.

I am running XAMPP to develop my code locally. My footer.php code looks like this:

<?php
echo '<link href="css/styles.css" rel="stylesheet" type="text/css" />';

?>
  • Can you fix your question please, the code is not included. – Spoody Oct 06 '17 at 18:37
  • 1
    Can you post your folder's structure – Spoody Oct 06 '17 at 18:37
  • The code seems fine. Make sure that the css file exists at that path. – mega6382 Oct 06 '17 at 18:40
  • Use a validator. It sounds like you are putting a `` somewhere it isn't allowed. https://validator.nu – Quentin Oct 06 '17 at 18:40
  • Do some basic debugging. Look at the generated HTML. Is it as you expect? If so then the PHP is irrelevent. Look at the Network tab. Is the request for the CSS made? What response do you get? – Quentin Oct 06 '17 at 18:40
  • D:\XAMPP\htdocs\CSUCH\css Where CSUCH has my index.php file – Christopher Austin Oct 06 '17 at 18:40
  • What I usually do is I link my CSS in my
    . The Javascript goes at the end of the page. Check https://stackoverflow.com/questions/18392418/html-css-put-link-tag-outside-of-the-head
    – Nic3500 Oct 06 '17 at 18:42
  • This is a PHP file not HTML file – Christopher Austin Oct 06 '17 at 18:44
  • @ChristopherAustin You should follow @Quentin's advice: Take a look at the HTML source code. Does it show the `` attribute? If not: are you including `footer.php` in your `index.php`? If yes: does the CSS file exist? What does the Network tab say? – masterfloda Oct 06 '17 at 19:49
  • It seems the issue I had was browser related. When I was accessing my site via localhost/website (xampp) on Google Chrome.. it wouldn't load any new style changes. However, I was able to see the changes immediately within Mozilla Firefox. Not sure why this was an issue.. but at least the issue was solved and the code is OK. – Christopher Austin Oct 10 '17 at 17:28

2 Answers2

0

If your application has any URL rewriting on the go, you'll want to make the CSS path relative to the root of the website:

href="/css/styles.css"

Check the network requests to ensure the CSS file can be found.

Fenton
  • 241,084
  • 71
  • 387
  • 401
0

It seems the issue I had was browser related. When I was accessing my site via localhost/website (xampp) on Google Chrome.. it wouldn't load any new style changes. However, I was able to see the changes immediately within Mozilla Firefox. Not sure why this was an issue.. but at least the issue was solved and the code is OK.