1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Referring to an external stylesheet confusion (formatting)

Discussion in 'CSS' started by tayiper, May 13, 2006.

  1. #1
    The URL is: http://users.volja.net/tayiper/index.html

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

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

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


    The URL is: http://users.volja.net/tayiper/other/projects.html

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

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

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


    The URL is: http://tadej-ivan.50webs.com/index.html

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

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


    The URL is: http://tadej-ivan.50webs.com/other/projects.html

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

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

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


    When I thought I have problems viewing my documents off-line (i.e. from hard-disk), I started to wonder the following. Are those variations above the same thing (if you refer to a file from your document in "current directory") ?? Also note that the "style.css" file is under the root and under other directory. I guess that the first case (where my site is hosted in a sub-directory itself) is the most "problematic" ...


    Thanks in advance, tayiper
     
    tayiper, May 13, 2006 IP
  2. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Hi,

    "style.css" is equal to "./style.css" but "/style.css" is meaningless.

    - P
     
    penagate, May 15, 2006 IP
  3. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #3
    <link rel="stylesheet" type="text/css" href="style.css" title="stylesheet" />
    Would look for it here: http://tadej-ivan.50webs.com/other/style.css

    <link rel="stylesheet" type="text/css" href="/style.css" title="stylesheet" />
    would look for it here: http://tadej-ivan.50webs.com/style.css

    <link rel="stylesheet" type="text/css" href="/other/style.css" title="stylesheet" />
    would look for it here: http://tadej-ivan.50webs.com/other/style.css


    '/' on it's own means root directory, which in most cases on the web it would be the domain name. So '/style.css' http://users.volja.net/style.css.

    ../ means directory up from the current and 'style.css' means look in current directory for the file.
     
    AdamSee, May 15, 2006 IP
  4. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Oops,

    I should have been more specific, I was referring to offline :) I did some testing and the / trick did not work.

    - P
     
    penagate, May 15, 2006 IP
  5. kk5st

    kk5st Prominent Member

    Messages:
    3,497
    Likes Received:
    376
    Best Answers:
    29
    Trophy Points:
    335
    #5
    You'd find testing a lot more 'real world' if you were to install Apache, PHP, MySQL, PERL and all the other expected hosted goodies. That way you could use includes, server side scripting, cgi scripts, &c., mimicing hosted results.

    cheers,

    gary
     
    kk5st, May 15, 2006 IP
  6. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #6
    Ah thanks, you know, in fact I just wanted to ask about these href="../" ones too. And also I thought/speculated that it is what you said it is, yes, it's all pretty much the same as hard-disk drive's structure and browsing through it in a command-line environment ...


    tayiper
     
    tayiper, May 15, 2006 IP
  7. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #7
    /UPDATE: Further thoughts ...


    Now I see why when I use the following code (see below) everything works fine on "http://tadej-ivan.50webs.com" site for instance (i.e. the browser looks for a file in a root), but would not work on the "http://users.volja.net/tayiper/" one.

    -- <a href="/articles.html">articles</a><br>-- <a href="/software.html">software</a>
    Code (markup):

    However on "http://users.volja.net/tayiper/ I use:

    -- <a href="/tayiper/articles.html">articles</a><br>-- <a href="/tayiper/software.html">software</a>
    Code (markup):
    -- <a href="/tayiper/other/specs.html">specs</a><br>-- <a href="/tayiper/other/events7.html">events7</a>
    Code (markup):
    ... and this seemed necessary/required to me for links to work. So you say I could simply use the "<link rel="stylesheet" type="text/css" href="style.css" title="stylesheet" />" variant to refer "current directory" ??


    tayiper
     
    tayiper, May 15, 2006 IP
  8. penagate

    penagate Guest

    Messages:
    277
    Likes Received:
    17
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Hi,

    I assumed by "offline from hard disk" it was not using a webserver (of which I do have several ;))

    Correct and that's the preferred way to do it. The other way is not using a relative path so it will break if you move the page at all. For websites you should always use relative paths (which includes ../ when the need arises).

    If the HTML file is located in /tayiper/ and the stylesheet is in /tayiper/styles, say, you can then use this:
    link rel="stylesheet" type="text/css" href="styles/style.css" title="stylesheet" />
    HTML:
    Very simple :)

    - P
     
    penagate, May 15, 2006 IP
  9. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #9
    Curious, but isn't this the same as (note the additional "slash" char):

    <link rel="stylesheet" type="text/css" href="/styles/style.css" title="stylesheet" />>
    Code (markup):
    /EDIT: Also, if refer to my "favicon.ico" file like this: "<link rel="icon" type="image/png" href="favicon.ico" title="icon" />", I should then put the file into all directories (i.e. the root and "other" one), similaly as with stylesheet case above ??


    tayiper
     
    tayiper, May 16, 2006 IP
  10. AdamSee

    AdamSee Well-Known Member

    Messages:
    422
    Likes Received:
    28
    Best Answers:
    0
    Trophy Points:
    135
    #10
    AdamSee, May 16, 2006 IP
  11. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #11
    Oh and yes, where is basically the difference between these two examples below that you've provided ...

    (of course, assuming that we are currently under the "other" directory)


    tayiper
     
    tayiper, May 16, 2006 IP
  12. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #12
    Well, which one of those two points to the root (in my opinion none) ??


    tayiper
     
    tayiper, May 16, 2006 IP
  13. tayiper

    tayiper Active Member

    Messages:
    421
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    78
    #13
    Well, I've experimented with various different combinations a bit more, and so I noticed this ...


    If I use the following code for links on the "Volja" free-host (which is itself located in a sub-directory)

    <a href="tayiper/links.html">links</a>
    Code (markup):
    <a href="tayiper/other/config.html">config</a>
    Code (markup):
    Then I am directed/pointed to ""tayiper/tayiper/links.html" and ""tayiper/tayiper/other/config.html" (and it's similar in src="tayiper/1x1-px.png" case), as you can nicely see in this example-document at "Volja" free-host: index-rel.html (or see similarly modified index-rel.html file at "50webs" free-host); note that I've left the href="style.css" part intact so that the layout is still displayed correctly ...


    tayiper
     
    tayiper, May 21, 2006 IP