SitePoint Sponsor

User Tag List

Results 1 to 5 of 5

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Apr 2012
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    image URLs in CSS

    Why can't I use /img/img.jpg to access the img folder from the root directory? I can link to css and js like so, or put a href to /index.php and it directs to the root index. But using /img/img.jpg just accesses sub directories. I wonder if there's a workaround or .htaccess method?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,165
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    No, that should work just fine, and it's the best way to link to images, IMHO. Are you doing this online or on your computer? Are you sure there's a folder called /img/ in your root folder?

  3. #3
    SitePoint Mentor bronze trophy
    ronpat's Avatar
    Join Date
    Jun 2012
    Location
    NJ, USA
    Posts
    2,505
    Mentioned
    61 Post(s)
    Tagged
    2 Thread(s)
    Any chance there is a space in the path/filename?

  4. #4
    Community Advisor silver trophybronze trophy
    dresden_phoenix's Avatar
    Join Date
    Jun 2008
    Location
    Madison, WI
    Posts
    2,796
    Mentioned
    34 Post(s)
    Tagged
    2 Thread(s)
    or perhaps, its because that code is in your styleSheet.css file, which is in a sub folder ? If that's the case, your relative path is off and you need to go up a directory ../images/img.jpg

  5. #5
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,165
    Mentioned
    453 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by dresden_phoenix View Post
    If that's the case, your relative path is off ...
    The OP is using a root-relative path, so it shouldn't matter.


Bookmarks

Posting Permissions

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