-1

I have created a very small personal website with three different pages and one CSS file. I know to embed a CSS file into an html page is the following:

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

but form some reason the CSS file only work in one page. Any advice please

3
  • have you added that code to all the html pages?
    – chyupa
    Feb 14, 2014 at 1:54
  • yeah i have added the code to all the html pages Feb 14, 2014 at 1:56
  • I have tried before, all files are in the same folder Feb 14, 2014 at 1:57

2 Answers 2

1

Did you checked your folders structure? You may have other html file in different folders.

I suggest to use an absolute path for your stylesheet. something like:

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

first / in href parameter is what I mean.

Edit: You may use a windows machine and upload your files into a Linux machine. Windows do not care about lowercase or uppercase, but it is important on Linux. rename all your filenames to lowercase every where and use it exactly the same in your code (check your link tags again). this may fix your problem

5
  • all my files are located in the same folder, its very strange because it works properly offline, but as soon as uploaded the files to the web it doesn't work Feb 14, 2014 at 1:59
  • I add something to my answer, check that again
    – Shahram
    Feb 14, 2014 at 2:22
  • That's normally referred to as root relative (leading slash).
    – steveax
    Feb 14, 2014 at 2:27
  • @steveax yes, that is what I mean. Thanks for remark
    – Shahram
    Feb 14, 2014 at 2:28
  • If you are fine on local, but there are issues on production I might suggest checking file permissions on the server. Also might not hurt to load an affected page in a browser, view source and also try to get to the css file directly through the browser. ie.. www.thewebsite.com/css/mystyle.css (changing the url) and see if the css file loads. Feb 14, 2014 at 2:33
0

Sharing the link of the site would be helpful. Make sure that the line of CSS aboves goes on each page. For example, if you have 3 pages with 3 different files: index.htm, bio.htm and contact.htm (I'm having to guess since I have not gotten this info from you). Then make sure the link to the CSS above appears on each of those pages.

1
  • yeah every single html files has the link to the CSS file, offline works but as soon as upload my files to the web it doesn't Feb 14, 2014 at 2:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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