Absolute URLs and relative URLs

Source: Internet
Author: User

What is a URL?

Application Example: Can be a picture, such as resource address, browser address bar URL, etc.

Uniform Resource Locator Uniform Resource Locator

Http://www.123.com/infor/index.html

A URL consists of four parts:

The first part: protocol, e.g. http://

The second part: domain name (or hostname, server name), such as: www.123.com

Third section: folders, such as: infor

Fourth part: File name, such as: index.html

?

In HTML, the concept of absolute and relative paths is involved whenever a file is involved (such as hyperlinks, images, etc.):

    1. Absolute URL

Absolute URL is the real path on the hard drive of the file or directory on the home page of your site

?

An absolute URL is a URL that always begins with a domain name (or/), which is the absolute URL.

Note: "/" represents the site root of the domain name.

Example: Http://www.baidu.com/image/baobao.gif

???? Tip: When using the absolute URL, only need to filter the target file is who, do not need to filter the current file is who.????

To reference a picture resource:

(2) Relative URL: Do the site with the most is the relative path

    • Implementation criteria for relative URLs:

A) who is the current file?

b) who is the target file? (Resource files that need to be introduced)

c) What is the relationship between the current file and the target file?

Peer Relationship : write the target file name directly????????????

Subordinate relationship : The target file under a folder, write the directory name of the sibling, and then write the file name under the directory. Images/baobao.gif

Parent Relationship : directory files in the previous level of the directory, first go up a level, then find the appropriate folder, and then find the file.

./Current File

????.. /go up one level

????.. /.. /go up two levels

????.. /day1/images/01.gif

Absolute and relative URLs

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.