How to get to the root?

Discussion in 'HTML' started by Samuël van Laere, Oct 12, 2004.

  1. Hi friendly people (yeah even you Brucie beast),

    I've just got a stupid question and it probally got an easy answer
    i'm sure I once knew how to do it, but I forgot, so here goes:

    root/style.css
    root/mydirectory/page1.html

    How can I include the style.css file into page1.html without using a
    absolute url?

    I'll try to remember it this time. :p

    With regards,
    Samuël van Laere
    the Netherlands
     
    Samuël van Laere, Oct 12, 2004
    #1
    1. Advertisements

  2. Samuël van Laere

    Neal Guest

    To refer to the root, start with / then indicate the path.

    In your case, you could use /style.css (static) or ../style.css (relative).
     
    Neal, Oct 12, 2004
    #2
    1. Advertisements

  3. Samuël van Laere

    Sam Hughes Guest

    .../style.css
     
    Sam Hughes, Oct 12, 2004
    #3
  4. Samuël van Laere

    brucie Guest

    In alt.html Samuël van Laere said:
    i really am a nice guy, people just use a nasty font in their
    newsreaders that makes me sound evil. try a nice VladimirScrD and you'll
    be pleasantly surprised.
     
    brucie, Oct 12, 2004
    #4
  5. While the city slept, brucie () feverishly typed...
    That's me, isn't it??

    At least he got your name right! ;-) (apart from the surname, of course...)

    Cheers,
    Nige
     
    nice.guy.nige, Oct 12, 2004
    #5
  6. Samuël van Laere

    marcus Guest

    <link rel="stylesheet" href="../style.css" type="text/css">
     
    marcus, Oct 13, 2004
    #6
  7. Samuël van Laere

    Karl Core Guest

    Um, no. Try again.

    -Karl
     
    Karl Core, Oct 13, 2004
    #7
  8. Samuël van Laere

    Neal Guest

    What's wrong with the above? I don't see it. Please point it out, and tell
    me what would be correct.

    It exactly parallels the line

    <LINK rel="stylesheet" href="bach.css" type="text/css">

    found at http://www.w3.org/TR/CSS21/intro.html . Except the ../ is used to
    point the browser up a directory relative to the current one, which is
    what OP wanted.
     
    Neal, Oct 13, 2004
    #8
  9. Samuël van Laere

    Karl Core Guest

    That does not necessarily lead to root. If the page in question is three
    directories deep and the style sheet is in the doc root, then it doesn't go
    deep enough.
    The answer would be <link rel="stylesheet" href="/style.css"
    type="text/css">


    -Karl
     
    Karl Core, Oct 13, 2004
    #9
  10. Samuël van Laere

    Neal Guest

    Yes, I agree. But the poster gave an example of the directory structure
    where the page was in the very next level (snipped in Marcus' reply).

    root/style.css
    root/mydirectory/page1.html

    For the OP's situation, it should work fine. Though it is also true that
    if the page were moved to a different directory level, unless the css file
    was moved similarly the relationship would break.
     
    Neal, Oct 13, 2004
    #10
  11. Samuël van Laere

    Karl Core Guest

    My apologies, Neal. I didn't see the OP, just Marcus' reply.

    -Karl
     
    Karl Core, Oct 13, 2004
    #11
  12. Samuël van Laere

    Toby Inkster Guest

    But the OP said:

    | How can I include the style.css file into page1.html without using a
    | absolute url?

    "/style.css" is absolute (though I believe it is what the OP wants deep
    down).
     
    Toby Inkster, Oct 13, 2004
    #12
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.