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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2008
    Location
    Jupiter
    Posts
    49
    Thanks
    8
    Thanked 0 Times in 0 Posts

    I need help linking images using their relative path names

    I have been switching to coding everything by hand this year. I have an image called google.jpg on my desktop and i want to add it as an image to a webpage that im building on my local machine and then view it. I only want to use the relative path, not the absoutle path. The code i have is


    <img src="google.jpg" width="1000" height="450" />.



    The image displays as an broken image. Im not sure how to link to files on my local machine using their relative path names. What am im doing wrong in my code, and any refernce links that can help me with linking to files on my local machine using their relative path names would be appreciated, thanks.

  • #2
    Regular Coder
    Join Date
    Nov 2006
    Posts
    247
    Thanks
    13
    Thanked 26 Times in 24 Posts
    In order for <img src="google.jpg" width="1000" height="450" /> to work, google.jpg would need to be in the same folder as the html file. Should work if the html file is also on your desktop.
    Last edited by Majoracle; 02-17-2009 at 12:33 AM.

  • #3
    Regular Coder
    Join Date
    Nov 2004
    Location
    The land of chocolate
    Posts
    226
    Thanks
    1
    Thanked 16 Times in 16 Posts

    Arrow

    That code only works if your html page is also located on your desktop (so, in the same folder as your image). You use "/foldername" to browse to a folder and "../" to go up a folder.

    Suppose you have a folder structure like this (folders are written in caps):
    Code:
    WEBSITE
      - index.html
      - IMG
           - image.jpg
    Then, if you want to show image.jpg in index.html, you do
    Code:
    <img src="img/image.jpg">
    If your folder structure is like this:
    Code:
    DOCUMENTS
      - WEBSITE1
           - IMG
                - image.jpg
      - WEBSITE
            - index.html
            - image2.jpg
    If you want to show both images in your index.html, you do it like this:
    Code:
    <img src="../website1/img/image.jpg">
    <img src="image2.jpg">
    I hope this is clear (and that I understood your question correctly ).
    -Snow

    Susie, if you want to see your doll again, leave $100 in this envelope by the tree out front. Do NOT call the police. You CANNOT trace us. You CANNOT find us.

    Sincerely,
    - Calvin.

  • #4
    New Coder
    Join Date
    Jun 2008
    Location
    Jupiter
    Posts
    49
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Thanks guys, i finally got it now, i repped both of your guys, thanks again.


  •  

    Posting Permissions

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