1. relative and absolute paths
There are three types of document paths: absolute path, root relative path, and document relative path.
The absolute path is the full path that includes the Server Protocol (in this example, HTTP). For example, the full path of "Hong Neng online-computer Park" is http://www.hongen.com/pc/index.htm. if you want to link a document outside the site, use absolute paths.
The relative path includes the root relative path (site root) and document relative path (document.
As mentioned above, when editing a webpage on a local disk, You need to select a folder to define the local site and simulate the root folder on the server, the system determines the local file location of all links based on this folder, and the root in the relative path refers to this folder.
The path to the relative path (also known as the relative directory) starts with "/". The path is calculated from the root directory of the current site. For example, the myweb directory of the d disk we created earlier is the site named "myweb". Then, the path "/index.htm" indicates that the file location is D: \ myweb \ index.htm. The root relative path applies to files in the environment frequently when the link content is changed, so that the link can still take effect even if the files in the site are moved.
If the directory structure is too deep, it is better to use the relative path when referencing the files under the root directory. For example, if a webpage file references a graph in the IMG directory under the root directory, the relative path of the document is displayed as: ".. /.. /.. /.. /.. /img/a.gif, and the relative path is expressed as "/img/a.gif.
Note: When previewing a file, content linked with the root relative path is not displayed in the local browser, because the browser does not recognize the root folder of the site as a server.
In this case, we can virtualize the root directory of the site into a disk. For example, if you want to browse files under D: \ myweb, you can select "run" in the Windows "start" menu to bring up the "run" dialog box.
Enter "subst I: D: \ myweb". The myweb folder on disk D is virtualized as an I disk, and you can view the webpage under disk I in a browser, the content linked with the root relative path can be displayed normally.
The relative path of a document refers to the folder containing the current document, which is calculated based on the folder where the current webpage is located. For example, if the current webpage is located at D: \ myweb \ mypic, then:
A.htm indicates D: \ myweb \ mypic \ a.htm;
"../A.htm" is equivalent to D: \ myweb \ a.htm, where "../" indicates the level-1 folder on the current folder.
"Img/a.gif" refers to D: \ myweb \ mypic \ IMG \ a.gif. "img/" indicates the IMG folder under the current folder.
The relative path of a document is the simplest path. Generally, it is used to link documents stored in the same folder.