Home > Article > Web Front-end > What is an absolute path, what is a relative path, and what is the difference between the two?
Recently when I was developing a project, I wanted to reference the bootstrap file, but I kept getting errors, so I wanted to study the relationship between relative paths and absolute paths to see what the difference is.
1. What are absolute paths and relative paths?
DIVCSS5 will introduce to you the basic knowledge, functions, usage and other knowledge of relative paths and absolute paths that HTML often talks about.
Relative path: The directory path created based on the location of the web page that references the file. Therefore, when web pages saved in different directories reference the same file, the paths used will be different, so it is called relative.
Absolute path: The directory path based on the root directory of the Web site. The reason why it is called absolute means that when all web pages reference the same file, the path used is the same.
In fact, the difference between absolute paths and relative paths lies in the reference points used when describing directory paths. Since the reference point of the root directory is the same for all files on the website, the path description method using the root directory as the reference point is called an absolute path.
2. Path special symbols
The following are several special symbols used to establish paths and their meanings.
"." -- Represents the current directory, relative path. For example: text or
".." -- represents the upper directory, relative to path. For example: text or
"../../" -- represents is the directory above the previous directory, a relative path. For example:
"/" -- represents the root directory, absolute path. For example: text or
"D:/abc/" -- represents the root directory, absolute path .
When using relative paths, we use the symbol "." to represent the current directory, and the symbol ".." to represent the parent directory of the current directory.
3. Popular explanation of path
Absolute path As the name suggests, filling in the absolute directory path address is called an absolute path. Usually we use "/" directly to represent starting from the root directory. directory path, this is called an absolute path.
Relative path, as the name suggests, when filling in the directory, use the directory file as a reference. Use "../" or "./" to point to the previous level or use "../../" to point to the previous level. This is called a relative path. .
Citer . ../SubDir2/BeRef1.gif .htm divcss5.gif ../../Dir1/SubDir2/ BeRef1.gif ../../Dir1/SubDir2/ BeRef1.gif
url3.htm abc1.htm . ../../Dir2/ abc1.htm ../../Dir2/ Dir2/abc1.htm
url4.htm abc2.htm ../abc2.htm ../abc2.htm . . . . . . . . . . . . Note:
We use "/", "../ ", "../../" respectively style and introduce the relative absolute path relationship between the image path and the URL path.4. What are the functions of absolute paths and relative paths?
Relative paths and absolute paths can be converted to each other. Just pay attention to the correct path when converting. The effect is the effective link path.
What is the relationship between relative path and absolute path and CSS? 1. When we introduce image addresses in CSS, we may use relative paths and absolute paths. 2. When we introduce CSS files in HTML in the html of DIV CSS, we will use them when introducing and adding images. Relative paths and absolute paths
The above is the detailed content of What is an absolute path, what is a relative path, and what is the difference between the two?. For more information, please follow other related articles on the PHP Chinese website!