Learning Essentials:
1. Properties of hyperlinks
2. Relative and absolute path
3. Anchor Point Settings
Keynote Teacher: Li Tinghui
This chapter focuses on the most important hyperlink of HTML5 Chinese text element, and discusses its own properties and path problems.
A Properties of a hyperlink
The <a> element is a text element, with some private attributes or local attributes. Then there is a generic property or a global property that corresponds to it. This knowledge will be discussed in detail later.
Property name |
Description |
Href |
Specifies the URL of the resource that the <a> element refers to |
Hreflang |
The language to which the linked resource is directed |
Media |
Describes which device the linked resource is used for |
Rel |
Describe the relationship type of the document to the linked resource |
Target |
Specify the browsing environment to open the linked resource |
Type |
Describes the MIME type of the linked resource (for example, text/html) |
Of these properties, only the HREF and target are commonly used, and the href must be used. Several other properties, less used in <a> elements, will be explored in the CSS section.
1.href Properties
<href= "http://www.baidu.com"> Baidu </a>
Explanation: HREF is a mandatory attribute, otherwise the <a> element becomes an empty element. If the property value is a URL that starts with http://, it means click to jump to the specified external site.
2.target Properties
<href= "http://www.baidu.com" target= "_blank"> Baidu </a>
Explanation: The target property tells the browser where to display the linked resource.
Property name |
Description |
_blank |
Open a document in a new Window or tab page |
_parent |
Open a document in the parent sash Group (FRAMESET) |
_self |
Open Document in current window (default) |
_top |
Open a document in the top-level window |
The four most commonly used are _blank, creating a new window. While _self is the default, the current window opens. _parent and _top are based on frames pages, respectively, that are opened in the parent window and open throughout the window. And HTML5, the framework is basically discarded, can only use <iframe> elements, and later a lot of combination of JavaScript and PHP and other languages, the framework is rarely used.
Two Relative and absolute paths
The so-called relative path is the path to another page relative to the linked page. The absolute path is the full path that starts directly from the file:///disk character. We do two pages in the same directory, one page linked to another.
1. Absolute path
<href= "file:///D:/lesson/HTML5 first season/code/index2.html">index2</ a>
Explanation: First, the file:///begins, then the disk character, then the directory hierarchy, to find the corresponding file. The most deadly problem in this way is that when the entire directory is moved to another drive or other computer, the link is immediately invalidated if any changes occur to the directory structure.
2. Relative path
<href= "index2.html">index2</a>
Explanation: The condition of the relative path is that the file must be in a disk or directory, and if it is in the same directory, the direct attribute value is the linked file name. suffix. If you have more than one subdirectory hierarchy in the same home directory, you need to use the directory structure syntax.
3. Directory syntax
Same directory: Index2.html or./index2.html;
In sub-directories: xxx/index2.html;
In the grandson directory: xxx/xxx/index2.html;
In parent directory:.. /index2.html;
In Grandpa directory:.. /.. /index2.html;
Three Anchor Point Settings
Hyperlinks can also be used to move another element in the same document into view. Anchor point positioning is implemented by property ID or name.
Link
<ahref= "#1">Chapter I.</a><ahref= "#2">Chapter II</a><ahref= "#3">Chapter III</a>
Anchor Point<aname= "1"></a><aID= "3"></a>
4th Hyperlinks and Paths