Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts

    Background images and path issues

    I just found out something interesting today at work, and I want to know if it's just a funky local system configuration, or if this is indeed true.

    I've got a web page (lets say index.html) with a css file attched like so:

    Code:
    <link href="/css/path/to/css/main.css" type="text/css" rel="stylesheet" />
    Then, within my css I have several background images...

    Code:
    #someID {
        background-image:url("/path/to/image/image.gif");
    }
    The thing I noticed is in the <link> tag, the root is the document root (i.e http://www.example.org/) but in the css declarations, the root is the directory that contains the css (in this case http://www.example.org/css/path/to/css/). This seems quite odd to me as I would expect "/" to ALWAYS go to the true document root. Anyone else experience this or am I going crazy?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    The Netherlands, Baarn, Ut.
    Posts
    4,252
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Base URL

    According to this description, the leading slash refers not to the document root but to the "base URL" (which is explained as well); since relative url(...) property values in stylesheets indeed start at the location the stylesheet is at, the behaviour you described would be correct.
    Regards,
    Ronald.
    ronaldvanderwijden.com


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •