Tutorial on using hyperlink tags in XHTML_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:46:10
Original
1550 people have browsed it


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:

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

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:

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

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

Example of added target attribute:

XML/HTML CodeCopy content to clipboard
  1. <a 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.
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:

XML/HTML CodeCopy content to clipboard
  1. <a href="mailto:admin@xyz .com">Contact the webmaster of xyz stationa>

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:

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

Create a hyperlink address linking to the anchor:

XML/HTML CodeCopy content to clipboard
  1. <p><a href="#comment">Link to comment anchora>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 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:

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

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.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!