SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jul 2009
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    About src attribute.

    I have a confusion with the src attribute. When I insert images in my web site using html, what is more correct with the src attribute: to write the relative location of the image on the root directory or write the URL address of that image? Which is the real difference?

  2. #2
    In memoriam gold trophysilver trophybronze trophy Dan Schulz's Avatar
    Join Date
    May 2006
    Location
    Aurora, Illinois
    Posts
    15,495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Using the relative image path (such as "images/file.jpg") will make the location relative to the Web page's location. If the path is correct and the user agent can follow the link then the image will be rendered. But if you move the page, it will likely break.

    Using an absolute path will ensure that the path doesn't break unless you physically move the image file. Note that you can achieve a similar effect with a relative path if you declare a root, like so: /images/filename.jpg -- note the addition of a forward slash just before the "images" directory name in the URI path.


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
  •