HTML webpage hyperlink markup learning tutorial
LINK tag attributes
Links are one of the most important elements on a webpage and the soul of a website. A website consists of multiple pages, and pages depend on links to determine their navigation relationships. Each web page has a unique address, which is called a url (Uniform Resource Locator: a common Resource identifier) in English ). Enter in the address bar and press enter to open the home page of the Web site. As you can see, there are multiple topics and news on the page. The different topics at the top are text links.
Although the link tag plays an irreplaceable role in website design and production, there is only one tag, that is, the <a> tag. The linked applications described on this site are based on the <a> mark.
The link tag attributes are shown in the following table.
Attribute description
Href specified link address
Name: name the link
Title prompt text for link
Target window of the specified link
Accesskey link hotkey
About path
Each file has its own storage location and path. Understanding the path relationship between a file and the file to be linked is the root of creating a link. Url-uniform resource locator refers to the unique address of each website. Each webpage under the same website belongs to the same address. However, when creating a webpage, it is impossible to enter a complete address for each link. We only need to determine the relative path relationship between the current document and the root directory of the site. Therefore, links can be divided into the following three types:
Absolute path
Like http://111cn.net
Relative path
Such as news/default.htm
Root path
For example,/website/news/default.htm
Before learning about the three address formats, you must understand the other two concepts: internal links and external links.
Both the internal and external links are relative to the site folder. If the link points to a file in the site folder, it is an internal link. If the link points out of the site folder, it is called an external link. When adding external links, the absolute address mentioned below will be used. When adding an internal link, the relative address of the root directory and the relative address of the file described below will be used.
These three links are described as follows:
Absolute path
The absolute path provides the complete path for the file, including the applicable protocol, such as http, Ftp, and rtsp. Common examples include:
Http://www.sohu.com
Ftp: // 202.136.254.1
When linking to files in other websites, you must use an absolute link.
Relative path
Relative links are most suitable for internal links of websites. As long as it is under the same website, even if it is not under the same directory, the relative link is also very suitable. The file relative address is an ideal form of writing internal links. As long as it is in the site folder, the relative address can freely build links between files. This address form uses the relative relationship between the two files that build the link, and is not affected by the server location where the site folder is located. Therefore, the same part of the absolute address is omitted. The advantage of this is that when the server address of the site folder changes, all the internal links of the folder (if this address is used) will not go wrong.
The relative link is used as follows:
If the link is to the same directory, you only need to enter the name of the document to be linked.
To link to a file in the next-level directory, you only need to enter the directory name, then add "/", and then enter the file name.
For example, to link to a file in the upper-level Directory, enter "... /", And then enter the directory name and file name.
Root path
The relative address of the root directory is also used to create internal links. However, this address format is not recommended in most cases. It is used in the following scenarios:
When the site is very large and is not deployed on several servers
When several sites are simultaneously placed on a server
The writing format of the root directory relative address is also very simple. First, it starts with a slash, representing the root directory, then writing the folder name, and finally writing the file name. The root path starts with "/" and then the directory name under the root directory.