HTML link
The various HTML documents of the website are connected to each other through hyperlinks to form a coherent website. Users can jump to the page they want to browse by clicking on the hyperlink. Therefore, hyperlinks can be seen in any website and are the core component of connecting websites to form a whole.
Arrangement of anchor points
HTML hyperlinks are triggered with the <a> tag as the anchor point. The anchor point needs to have a carrier, and this carrier It can be a text, a word, a sentence, an image or a shape. When the mouse moves to a carrier with an anchor point, the mouse will turn into a small hand, indicating that the user can click. After the user clicks on the anchor point, it will jump to the address corresponding to the href in the <a> tag. .
Usage of jump attribute
In HTML links, use the href attribute to create a link to another document, usually used for page jumps. This is very common and will not be explained again.
Use the name attribute to create a bookmark inside the document so that a hyperlink can jump to a certain part of the page within the document. For example: set <a name=”dian1″></a> to place it in the middle of the page. Then set the <a href=”#dian1″> jump to the middle of the page </a> anchor point at the head of the page. When the user clicks this anchor point at the head of the page, the page will scroll and jump to the name bookmark. The location is in the middle of the page.
HTML link syntax
HTML link code is very simple to use. For example:
<a href="url">Anchor text link</a>
href attribute is used To set the jump target, the text between the start tag and the end tag is displayed as a hyperlink.
The target attribute of HTML link
The target attribute can set the opening method of the page after clicking on the anchor text. There are four reserved target names used for special document redirection operations:
_blank
The browser always loads the target document in a newly opened, unnamed window.
_self
The value of this target is the default target for all <a> tags that do not specify a target, which causes the target document to be loaded and displayed in the same frame or window as the source document . This target is redundant and unnecessary unless used in conjunction with the target attribute in the <base> tag of the document title.
_parent
This target causes the document to be loaded into the parent window or frameset containing the frame referenced by the hyperlink. If this reference is in a window or in a top-level frame, it is equivalent to target _self.
_top
This goal causes the document to load into the window containing the hyperlink. Using the _top goal will clear all contained frames and load the document into the entire browser window. Generally, it is used to click the anchor point in the iframe frame. The target link is opened directly on the current page instead of being loaded in the iframe.
HTML Connection - id Attribute
The id attribute can be used to create bookmark tags in an HTML document.
Tips: Bookmarks are not displayed in any special way and are not displayed in HTML documents, so they are hidden from readers.
Example
Insert ID in HTML document:
<a id="tips">Useful tips section</a>
Create a link to the "Helpful Tips section (id="tips")" in the HTML document:
<a href="#tips">Visit Helpful Tips Section</a>
Alternatively, create a link to the "Helpful Tips Section (id="tips")" from another page:
<a href="http://www.php.cn/html/html-links.html#tips">
Visit the helpful tips section</a>
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> </head> <body> <a href="http://www.php.cn/" target="_blank">php中文网!</a> <p>如果你将 target 属性设置为 "_blank", 链接将在新窗口打开。</p> </body> </html>