About relative paths and absolute paths

Source: Internet
Author: User

relative path : The directory path that is established based on the location of the page where the file is referenced. Therefore, when a Web page that is saved in a different directory references the same file, the path used will not be the same, so it is referred to as relative.

Absolute path : The directory path that is based on the Web site's root directory. This is called absolute, meaning that when all Web pages reference the same file, the path used is the same.

In fact, the absolute path and the relative path are different, only in describing the directory path, the reference points used are different. Because the reference point of the root directory is the same for all files on the Web site, the path description using the root directory as the reference point is called the absolute path.

Second, path special symbol-TOP

The following are some of the special symbols used to establish the path, and the meanings they represent.

"."--Represents the current directory, relative path. such as: <a href= "./abc" > Text </a> or
"..."--represents the previous level of the directory, relative to the path. such as: <a href= ". /abc "> Text </a> or
".. /.. /"-Represents the previous level of the previous level of the directory, relative to the path. such as:
"/"--Represents the root directory, the absolute path. such as: <a href= "/ABC" > Text </a> or
"D:/abc/"--Represents the root directory, the absolute path.

When using a relative path, we use the symbol "." To represent the current directory, with the symbol "..." To represent the parent directory of the current directory.

Third, popular explanation path-TOP

Absolute path as the name implies, fill in the absolute directory path address that is called absolute path, usually we directly use "/" to represent the directory path starting from the root directory, this is called the absolute path.
Relative path as the name implies, fill in the directory when the catalog file for reference, use ". /"or"./"refers to the upward level or use". /.. /"point to the higher level called the relative path.

Relative path absolute path of the referenced person by reference

Url1.htm Divcss5.gif. /subdir2/beref1.gif/dir1/subdir2/beref1.gif

Url2.htm Divcss5.gif. /.. /dir1/subdir2/beref1.gif/dir1/subdir2/beref1.gif

Url3.htm abc1.htm. /.. /dir2/abc1.htm/dir2/abc1.htm

Url4.htm abc2.htm. /abc2.htm/dir2/abc2.htm

Description
We use "/", ". /”、“.. /.. /"Separate styles and describes the path of the picture and the URL path relative to the absolute path relationship.

What is the role of absolute path and relative path? -TOP

Both the relative and absolute paths can be converted to each other, and the correct path can be paid attention to when the conversion takes effect in a valid link path.

About relative paths and absolute paths

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.