How to use absolute paths and relative paths in html

php中世界最好的语言
Release: 2017-11-23 16:29:38
Original
4609 people have browsed it

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

picture

path 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 articles!

Related reading:


How to use HTML5
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!