Hi this is the first time I am asking a question here.
I have a image src as
src="images//images/pixel.gif"
But I dont understand this double forward slashes (//) in the src.
Also what is the meaning of "./" and "../" in a relative file path like in below src:
src="./images/pixel.gif"
src="../images/pixel.gif"
Relative pathsIf you don't supply the root, it means that your path is relative. The simplest example of relative path is just a file name, like index. html . So one should be careful with relative paths. If your current directory is /about/ then index.
A relative URL is a URL that only includes the path. The path is everything that comes after the domain, including the directory and slug. Because relative URLs don't include the entire URL structure, it is assumed that when linking a relative URL, it uses the same protocol, subdomain and domain as the page it's on.
A relative path refers to a location that is relative to a current directory. Relative paths make use of two special symbols, a dot (.) and a double-dot (..), which translate into the current directory and the parent directory. Double dots are used for moving up in the hierarchy.
An absolute path refers to a file on the Internet using its full URL, e.g. "http://www.uvsc.edu/disted/php/webct/itr/index.php" A relative path assumes that the file is on the current server, e.g. "php/webct/itr/index. php".
An initial /
means the root of the web page.
A directory entry with name .
means the same directory. If it's at the beginning, it normally means something like "here" and mostly used to clarify that the path is relative to the present location.
A directory entry with name ..
means the parent directory. So, this means going up the directory tree.
If two or more /
are consecutive, this cancels all previous path and replaces with the root of the web page.
That said,
src="images//images/pixel.gif"
means /images/pixel.gif
(directly at the root directory, a folder with name images
, and then the file.
src="./images/pixel.gif"
means a directory images
inside the same directory where the loaded page resides (the one containing the reference to the image). Remember the here concept. You could also write directly src="images/pixel.gif"
.
src="../images/pixel.gif"
means going up to the parent directory in which resides the loaded page and then go down to a directory named images
. Remember the parent concept.
Hope helped!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With