Help, How To Get CSS for different than root directory?

Discussion in 'CSS' started by Franck S, Mar 7, 2007.

  1. #1
    It is my first site with CSS, and I am facing my first CSS problem ever!

    Here is what I've done so far:

    * I uploaded my CSS folder into the root directory.
    * I uploaded my index pages and other pages into the root directory.

    Below is the link for the CSS:
    <link rel="stylesheet" href="css/style.css" type="text/css">


    ==> Result: everything is fine.

    Here is the problem:

    I created a new directory, and then uploaded a page to this directory.

    Here is the problem: That page in the new directory (http://www.mysite/newdir/page.html) doesn't take the CSS specificities.

    My question: Should I upload the CSS file in each directory? I think I have to add this line: ../css/style.css

    So that <link rel="stylesheet" href="css/style.css" type="text/css"> will become:

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

    Who can help me?
     
    Franck S, Mar 7, 2007 IP
  2. Franck S

    Franck S Peon

    Messages:
    775
    Likes Received:
    19
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I've just resolved the problem.
     
    Franck S, Mar 7, 2007 IP
  3. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #3
    It would have been the polite thing to explain how you resolved the issue, as there are likely others with the same question.

    cheers,

    gary
     
    kk5st, Mar 7, 2007 IP
  4. ajsa52

    ajsa52 Well-Known Member

    Messages:
    3,426
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    160
    #4
    A possible solution would be creating a symbolic link for newdir/css pointing to css. This way:
    
    cd newdir
    ln -s ../css .
    
    Code (markup):
    That way you can use the same "href" for your stylesheet on all your pages
    .
     
    ajsa52, Mar 7, 2007 IP
  5. wmtips

    wmtips Well-Known Member

    Messages:
    601
    Likes Received:
    70
    Best Answers:
    1
    Trophy Points:
    150
    #5
    If you place a / (slash) symbol first, the path will be counted from the website root directory. So the solution is
    <link rel="stylesheet" href="/css/style.css" type="text/css">
    HTML:
     
    wmtips, Mar 7, 2007 IP
    kk5st likes this.