When wereferencefiles, each path is different. Today we will discuss the similarities and differences between absolute paths and relative paths, so that we can distinguish reference paths in the future. Pros and cons.
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 paths used are 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.
Path special symbols
The following are several special symbols used to establish paths and their meanings.
"." -- Represents the current directory, relative path. For example:textor
".." -- represents the previous layer Directory, relative path. For example:textor
"../../" -- represents the directory above the previous directory, a relative path. For example:
"/" -- represents the root directory, absolute path. For example:textor
"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.
Popular explanation of path
Absolute path As the name suggests, filling in the absolute directory path address is called an absolute path. Usually we directly use "/" to represent the directory path starting from the root directory. 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. It's called a relative path.
Referencer ../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 /Dir2/abc2.htm
Description:
We use "/", " ../" and "../../" respectively style and introduce the relative absolute path relationship between the
picturepath and the URL path.
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, absolute path and CSS?
1. When we introduce image addresses in CSS, we may use relative paths and absolute paths.
2. We introduce CSS files in HTML in DIV+CSS html and import
When adding pictures, relative paths and absolute paths will be used
The above is the relationship between absolute paths and relative paths. I believe everyone has understood it clearly through our introduction. For more exciting content, please pay attention to php Chinese website
Other Related reading: