![]() |
|
Relative and Absolute Paths in HTML, Free online HTML Tutorial, Learn HTML online for free... |
| Lessons | Relative and Absolute Paths in HTML |
|
|
Absolute Paths: Absolute path refers to the locatoin of the file with reference to the root directory, in the case of a file system, or full web address in the case of a domain name. For example: C:\myWeb\images\logo.jpg http://www.domainname.com/images/logo.jpg The first one is the example of an absolute path of the image file in the local file system and the second one is the example of an absolute path of an image file on a web server. Relative Paths: Relative path refers to the location of the file with reference to the current directory. For example if you are currently working in a directory named myWeb and want to refer to the image file named logo.jpg located in a directory named images stored inside myWeb directory, you can point to it using its relative path as under: images\logo.jpg In this case you need not to specify full file system path. In the case of a web server if your html file is on the root and your image file logo.jpg is strored in the images folder, you can point to it using its relative path as under: images/logo.jpg Please note the difference between referencing a file on a file system and on a web server. On a file system \ is used and on a web server / is used. While writing HTML you will most often encounter web server / type paths. Please don't mix them as the file system example has been given just as a reference.
Next >>> Lesson No. 20: Image Handling in HTML
|