slash ( / ) before path or not

3 replies
  • WEB DESIGN
  • |
Hi,
when using relative paths to images, do you use a slash (/images/1.jpeg) before or not?
And what is the best method?
#path #slash
  • Profile picture of the author ronc0011
    It depends on where the image is relitive to the calling page. Try it both ways if you are unsure of the folder structure.

    If the calling page is in the root folder of the site and the "images" folder is also in the root folder then you don't use the "/"
    {{ DiscussionBoard.errors[3546587].message }}
  • Profile picture of the author RyanAndrews
    Since your images are in a specific image folder (Good idea), then yes you do have the leading slash.
    {{ DiscussionBoard.errors[3546992].message }}
  • Profile picture of the author SteveJohnson
    The first slash denotes 'document root' of your server setup. So an address that begins with a slash is sort of "relatively absolute" meaning that the address is relative to the document root rather than relative to the current address.

    So if your current page is http: //mydomain.com/folder/folder/current.htm an image address of "/images/pic.jpg" will come from //mydomain.com/images/pic.jpg. An image with address of 'images/pic.jpg" would come from mydomain.com/folder/folder/images/pic.jpg.

    See the difference?
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[3547347].message }}

Trending Topics