URL,HREF,SRC differences

Source: Internet
Author: User
Tags gopher file transfer protocol

URL (Uniform Resource Locator)

A Uniform Resource Locator is a concise representation of the location and access methods of resources that can be obtained from the Internet, and is the address of standard resources on the Internet. Each file on the Internet has a unique URL that contains information that indicates the location of the file and how the browser should handle it.

Structure

The base URL contains the schema (or protocol), the server name (or IP address), the path, and the file name, such as "Protocol://authorization/path? Query". The general Uniform Resource Identifier syntax for the complete, authoritative section looks like this: protocol://Username: password @ subdomain. Domain name. TLD: Port number/directory/filename. file suffix? parameter = value # flag

The first part:

Mode/Protocol (scheme): It tells the browser how to handle the file that will be opened. The most common pattern is the Hypertext Transfer Protocol (Hypertext Transfer Protocol, abbreviated to HTTP), which can be used to access the network. 1 Other agreements are as follows:

    • http--Hypertext Transfer Protocol Resources
    • https--Hypertext Transfer Protocol with Secure Sockets Layer
    • ftp--File Transfer Protocol
    • mailto--e-mail address
    • ldap--Lightweight Directory Access Protocol search
    • file--Local computer or share files on the Internet
    • News--usenet News Group
    • Gopher--gopher protocol
    • Telnet--telnet protocol

Part II:

The name or IP address of the server where the file resides, followed by the path to the file and the name of the file itself. The name or IP address of the server is sometimes followed by a colon and a port number. It can also contain user names and passwords that must be exposed to the server. The path section contains the path definition for the hierarchy, which is generally separated by a slash (/) between the different parts. The query section is typically used to transfer parameters that are required to dynamically query the database on the server.

Classification

1. Absolute URL

An absolute URL (absolute URL) displays the full path of the file, which means that the absolute URL itself is in a location independent of the location of the referenced actual file.

2. Relative URL

The relative URL (relative URL) describes the location of the destination folder as a reference point in the folder that contains the URL itself. If the target file is in the same directory as the current page (that is, the page that contains the URL), then the relative URL of the file is only the filename and extension, if the target file is in a subdirectory of the current directory, then its relative URL is a subdirectory name followed by a slash, then the file name and extension of the destination.

If you want to reference a file in a higher-level directory in the file hierarchy, use two periods and a slash. You can combine and reuse two periods and a slash to refer to any file on the hard disk where the current file is located, generally, you should always use relative URLs for files on the same server, they are easier to enter, and it is easier to transfer pages from the local system to the server. As long as the relative position of each file remains the same, the link is still valid.

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, absolute path. such as: <a href="/abc">文本</a> or
    • D:/abc/: Represents the root directory, 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.

Focus: Definition and distinction of href and src

The href and src are different, and they cannot be replaced with each other. We use SRC on replaceable elements, but the href is used to establish a relationship between the documents involved and the external resources.

href (hypertext Reference) specifies the location of a network resource to define a link or relationship between the current element or the current document and the desired anchor or resource defined by the current attribute. When we write down:

<link href="style.css" rel="stylesheet" />

The browser understands that the current resource is a stylesheet, and the page resolution is not paused (because the browser needs a style rule to draw or render the page, the rendering process may be paused). This is not the same as putting the contents of the CSS file in the <style> tag, so it is recommended to use the link tag instead of @import to import the stylesheet into the HTML document.

The SRC (Source) property embeds only the current resource to the location defined by the current document element. When the browser finds

<script src="script.js"></script>

The loading and processing of the page before the browser is downloaded, compiled, and executed will be paused. This process is similar to putting the JS file in the <script> tab. This is also recommended to put the JS file to load the bottom of the reason. Of course, the IMG tab is similar to this. The browser pauses loading until the image is extracted and loaded.
Similar to IMG There are more: replaced elements.

Reprinted from: 1190000002877022

URL,HREF,SRC differences

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.