0

I'm learning to code websites. I decided to start using fedora. All is well until i find that my CSS file isnt loading correctly. The same configuratiin worked in chrome for windows but not FF for linux.

I have a folder /home/cromwell/projects inside of which I have an index.html and a styles.css (as well as associated resources)

I reference the css file with href="styles.css"'... I also tried ./styles.css and file:///C:/home/cromwell....

The ./ method resolves and shows my css file when i click the link in "view page source". But it does not populate to the DOM when the page loads.

The css file is nothing more than a normalize. And the html only references the stylesheet. No content.

Why won't my css load? This setup was working in Windows... Do I need to set up an apache server? Is there a syntax to the path im missing?

2

You need to put your files to a public accessible folder. That is the only time you can load the CSS file. As a safe trick, put your css file on the same folder of your html file then use this linking code

<link rel="stylesheet" type="text/css" href="mycss.css">

You won't be able to use file:///C:/home/cromwell.... since Fedora have no concept of drive letters as default, it sees everything as folders unless you mount a drive and give it a drive letter.

It is also a big no to include a drive letter to your html links since it will search the file local to the visitors hard drive.

1

As far as I can tell, the only problem here is that there is no C:. The idea of giving drives (or partitions, or network shares) letters is a peculiar idiosyncrasy of DOS carried over to Windows. In Linux, there is one unified tree, and it starts at /. Other partitions/drives/shares may be mounted into that tree, but from a user perspective, you don't need to care about. So, you just need to reference your files at file:///home/cromwell/...

  • A apologize. The problem was a standard silly mistake. I was using a meta tag when i should have had a link tag... Which is not helpful for anyone else. Thank you for trying and sorry for wasting your time – Konner Rasmussen Feb 12 '16 at 7:48
  • You're welcome. And in any case this is still also true. – mattdm Feb 12 '16 at 8:47
0

I was using the wrong tag... Had a meta when i needed a link... Im sorry and thank you for your excellent answers

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.