What is the difference between src=“/images/logo.gif” and src=“images/logo.gif”?

前端 未结 3 1302
余生分开走
余生分开走 2020-12-18 04:54

is equivalent to


But



        
相关标签:
3条回答
  • 2020-12-18 05:26

    images/logo.gif

    It's relative and means: Go to a folder called images and then get the resource logo.gif

    ./images/logo.gif

    It's relative and means: From the current folder (the dot means this) go to a folder called images and then get the resource logo.gif

    As you can see the first two mean the same, finally the last one

    /images/logo.gif

    It's absolute and means: From the root of the web server or the file system or whatever (the slash means this) go to a folder called images and then get the resource logo.gif

    0 讨论(0)
  • 2020-12-18 05:43

    The third one is looking relative to the root of the site, so if you were on a page at:

    http://entrian.com/somewhere/page.html
    

    it would look in:

    http://entrian.com/images/logo.gif
    

    ignoring the somewhere piece of the page's address.

    0 讨论(0)
  • 2020-12-18 05:43

    In the document root. The first two are relative paths, while the last is an absolute path.

    0 讨论(0)
提交回复
热议问题