Home >Web Front-end >HTML Tutorial >Tutorial on using hyperlink tags in XHTML_HTML/Xhtml_Web page production
Hyperlink, also called "link". Hyperlinks can be said to be everywhere on the web pages we browse. When we click on a link address on a web page, it links to another web page. This is how hyperlinks work.
Use the tag to define a hyperlink, syntax:
Displayed text or image
Example:
Browser display effect:
Link to Baidu
When we click on the words "Link to Baidu" above, the browser will redirect to the Baidu homepage.
Hyperlink attribute
Hyperlink attribute:
href link address. It can be an absolute web address or a relative address.
target link target. A value of _blank will open the link address in a new window. By default, the current window will be used to open the link address.
name anchor link, we will talk about this separately below.
Relative web link address:
This example uses a relative address, while the example linking to Baidu above uses an absolute address.
Example of added target attribute:
When you click the link again, the browser will enable a new page to open the link address, while the original page window will be retained.
Tips
When a link address is not very closely related to the current topic or process, the target="_blank" attribute is usually enabled. Otherwise, try not to open a new window in order to give viewers a friendly browsing experience.
If the page is composed of several page frames, the target attribute can also have other values
Email hyperlink
Email link example:
Clicking this link will enable your default email client to compose your email.
Anchor link
Anchor link refers to the link within the page, but now many people also call text hyperlinks anchor links.
Let’s take an example to explain the role of anchor:
For example, we have a well-written article, and many people have commented at the end of the article, and the window for posting comments is usually at the bottom of the comment. Location. The website will set an anchor link where the comment is posted, and design a link to the anchor link where the comment is displayed, such as: "Post a comment." If someone does not want to view the comments left by others and wants to jump to the comment input window immediately, then click "Post a Comment" to quickly jump to the comment input window within the industry. This design undoubtedly improves the user experience for viewers.
Example of using anchor link
Creating an anchor:
Create a hyperlink address linking to the anchor:
As can be seen from the example, to access an anchor, just add the "#" sign and the name of the anchor after the link address. In the above example, since it is an anchor linking to this page, the previous link address is ignored (note: the relative address is actually ignored, and will not be discussed here).
Tip
If you want to experiment with the use of this anchor tag, be careful to keep enough web space between the hyperlink to the anchor and the anchor tag to see the effect. You can use the line break tags we learned above to create enough white space above and below to test.
You can also create an anchor tag that links to other pages, for example:
Of course, the page www.abc.com needs to have the test anchor tag, otherwise it will only link to the www.abc.com page and ignore the anchor tag.