somebody clear me what are relative and absolute paths ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

somebody clear me what are relative and absolute paths ?

what happens when we use relative and absolute paths?

6th Oct 2017, 6:42 AM
pragati kandel
pragati kandel - avatar
2 Answers
+ 4
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): https://www.sitename.com/path/to/resource/file.htm 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.
6th Oct 2017, 7:33 AM
Ipang
+ 2
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.
6th Oct 2017, 6:47 AM
Daniel Elder
Daniel Elder - avatar