SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Thread: <img src=???

  1. #1
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <img src=???

    Hi Everyone,

    I was wondering if someone could show me what I'm missing with is problem?

    When placing a picture inside a web page everything I've read so far says to do it this way:

    <img src="happy.gif" alt="happy" /> ect...

    This does not work for me.

    I seem to always have to write the complete file path, example:

    <img src="file///C:/.../.../.../happy.gif" />

    Something like that.

    Anyway, I realize this won't work when I upload my pages as the file paths will all change. I have one folder I keep all my web stuff in.

    Thanks

  2. #2
    SitePoint Enthusiast dotcompals's Avatar
    Join Date
    Jul 2007
    Location
    India
    Posts
    29
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try

    <img src="/happy.gif" alt="happy" />
    instead of
    <img src="happy.gif" alt="happy" />

  3. #3
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok,

    I'm going to try that right now. Let you know.

    Thanks

  4. #4
    Team SitePoint AlexW's Avatar
    Join Date
    Apr 2000
    Location
    Melbourne
    Posts
    832
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Freejoy View Post
    Hi Everyone,

    I was wondering if someone could show me what I'm missing with is problem?

    When placing a picture inside a web page everything I've read so far says to do it this way:

    <img src="happy.gif" alt="happy" /> ect...

    This does not work for me.

    I seem to always have to write the complete file path, example:

    <img src="file///C:/.../.../.../happy.gif" />

    Something like that.

    Anyway, I realize this won't work when I upload my pages as the file paths will all change. I have one folder I keep all my web stuff in.

    Thanks
    Freejoy, this piece of code --
    HTML Code:
    <img src="happy.gif" alt="happy" />
    -- will only work if your image is in exactly the same folder as your HTML file. Looking at the code above, it looks like you image is somewhere else on your computer.
    Alex Walker
    SitePoint Developer
    SitePoint - Learnable

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    A relative path like src="happy.gif" is relative to the HTML document that contains the <img> tag. In this case, it expects the image file to reside in the same directory as the HTML file.

    A path like src="images/happy.gif" indicates a file in a subdirectory named images below the HTML file's directory.

    Relative paths can also travel up in the directory tree. Let's say your HTML file is in C:\website\html\index.html and your image file is in C:\website\images\happy.gif. You can then use src="../images/happy.gif", where '..' indicates the parent directory.

    A root-relative path like src="/happy.gif" is relative to the root directory. If you're opening the page from your C: drive on a Windows system, this path points to the file C:\happy.gif. On a web server, it points to a file in the root directory of your site.

    You probably don't want to use src="file:///...", at least not if you intend to upload the page to a web server, because then it will stop working.
    Birnam wood is come to Dunsinane

  6. #6
    SitePoint Addict
    Join Date
    Mar 2008
    Location
    Sterling, CO
    Posts
    275
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Resolved!


    Thanks everyone. It was driving me nuts!

  7. #7
    SitePoint Member jimbo320's Avatar
    Join Date
    Apr 2008
    Location
    NC
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Freejoy View Post
    Hi Everyone,

    I was wondering if someone could show me what I'm missing with is problem?

    When placing a picture inside a web page everything I've read so far says to do it this way:

    <img src="happy.gif" alt="happy" /> ect...

    This does not work for me.

    I seem to always have to write the complete file path, example:

    <img src="file///C:/.../.../.../happy.gif" />

    Something like that.

    Anyway, I realize this won't work when I upload my pages as the file paths will all change. I have one folder I keep all my web stuff in.

    Thanks
    Try making a image folder in the same folder as your site and linking all your images to that.

  8. #8
    SitePoint Zealot
    Join Date
    Apr 2008
    Posts
    125
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    glad u got it resolved
    Last edited by web67; Apr 15, 2008 at 18:47.
    Keep Up to date about everthing Website Flipping
    Find out how to same thousands on your Mortgage Broker fees.


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
  •