Tutorial on using hyperlink tags in XHTML

Tutorial on using hyperlink tags in XHTML


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, we are linked to another web page. This is the hyperlink in action.
Use the <a></a> tag to define a hyperlink. The syntax is:
<a href="url">Displayed text or image</a>
example:

XML/HTML CodeCopy content to clipboard
  1. <   href = "http://www.baidu.com/" > Link to Baidu </ a >   

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 Properties
Hyperlink properties:
href link address. It can be an absolute web address or a relative address.
target The link target. A value of _blank will open the link address in a new window. By default, the link address will be opened in the current window.
name anchor link, which we will talk about separately below.

Relative web link address:

XML/HTML CodeCopy content to clipboard
  1. <   href = "/css"   target = "_blank" > DIV+CSS Tutorial </ a >   

This example uses a relative address, while the example linked to Baidu above uses an absolute address.

Example with added target attribute:

XML/HTML CodeCopy content to clipboard
  1. <   href = "http://www.baidu.com/"   target = "_blank" > Link to Baidu </ a >   

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.
Tip: When a link address is not closely related to the current topic or process, the target="_blank" attribute is usually enabled. Otherwise, try not to enable a new window to provide viewers with 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:

XML/HTML CodeCopy content to clipboard
  1. <   href = "mailto:[email protected]" > Contact the webmaster of xyz site </ a >   

Clicking this link will enable your default email client to compose an email.

Anchor Links
Anchor links refer to links within a page, but now many people also call text hyperlinks anchor links.
Let's take an example to explain the role of anchors:
For example, if we have a well-written article, many people will comment on it, and the window for commenting is usually at the bottom of the comments. The website will set an anchor link where the comments are posted, and design a link to the anchor link where the comments are 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 clicking "Post a Comment" will quickly jump to the comment input window within this industry. This design undoubtedly improves the user experience of viewers.
Example of using anchor link to create anchor:

XML/HTML CodeCopy content to clipboard
  1. < p > < a   name = "comment" > </ a > </ p >   

Create a hyperlink to an anchor:

XML/HTML CodeCopy content to clipboard
  1. < p > < a   href = "#comment" > Link to comment anchor </ a > </ p >   

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 links to the anchor of this page, the previous link address is ignored (Note: it is actually the relative address that is ignored, which will not be discussed here).
Tip: If you want to experiment with the use of this anchor tag, then be careful to keep enough space on the web page between the hyperlink to the anchor and the anchor tag to see the effect. We can use the line break tags we learned above to create enough white space above and below to test this.
You can also create an anchor tag that links to other pages, for example:

XML/HTML CodeCopy content to clipboard
  1. < p > < a   href = " http://www.abc.com/#test " > Link to anchor </a> </p>   

Of course, the test anchor tag must be present on the www.abc.com page, otherwise it will only link to the www.abc.com page and ignore the anchor tag.

<<:  Understanding and application of JavaScript ES6 destructuring operator

>>:  MySQL database implements OLTP benchmark test based on sysbench

Recommend

Solution to mysql error when modifying sql_mode

Table of contents A murder caused by ERR 1067 The...

Detailed explanation of TIMESTAMPDIFF case in MySQL

1. Syntax TIMESTAMPDIFF(unit,begin,end); Returns ...

W3C Tutorial (11): W3C DOM Activities

The Document Object Model (DOM) is a platform, a ...

Detailed explanation of Nginx rewrite jump application scenarios

Application scenario 1: Domain name-based redirec...

Complete steps to use samba to share folders in CentOS 7

Preface Samba is a free software that implements ...

Detailed method of using goaccess to analyze nginx logs

Recently I want to use goaccess to analyze nginx ...

Detailed explanation of Mysql logical architecture

1. Overall architecture diagram Compared to other...

Detailed explanation of Docker Swarm service orchestration commands

1. Introduction Docker has an orchestration tool ...

A few front-end practice summaries of Alipay's new homepage

Of course, it also includes some personal experien...

MySQL view principles and basic operation examples

This article uses examples to illustrate the prin...

Native JS to achieve sliding button effect

The specific code of the sliding button made with...

How to track users with JS

Table of contents 1. Synchronous AJAX 2. Asynchro...

Tips on disabling IE8 and IE9's compatibility view mode using HTML

Starting from IE 8, IE added a compatibility mode,...

Summary of 4 methods of div+css layout to achieve 2-end alignment of css

The div+css layout to achieve 2-end alignment is ...