somebody clear me what are relative and absolute paths ? | SoloLearn: Learn to code for FREE!


somebody clear me what are relative and absolute paths ?

what happens when we use relative and absolute paths?


10/6/2017 6:42:21 AM

pragati kandel

2 Answers

New Answer


Absolute path is formed by static full path to the resource, while the relative path is formed by reference to other path in relation to the current path. Example of absolute path (it's not a valid link, don't bother the click): Example of relative path: Consider the following directory structure; | root | + / html | - / css - / themes + / dark + / light | + / js Assuming we are working in the html subdirectory, a relative path to a file in css, or js subdirectory, a relative path would look like: ../css/file.css ../js/file.js If you're targeting a resource on one of the subdirectories of themes directory: ../css/themes/dark/file.css ../css/themes/light/file.css Note: A single period (.) in a path points to the directory itself, a double period (..) points to a directory on a higher level. Relative path is considered simpler opposed to absolute path in case your domain/directory name change.


Relative paths are file paths from there you are working to the specified file. Absolute paths are disk paths (or web URLs) and are this unchanging. If you move a folder containing your code with relative paths, it will be okay, but if you do the same with absolute paths, it will break. Both have their purposes.