HTML- table

HTML links

HTML uses a hyperlink connected to another document on the network.

Links can be found in almost all of the pages. Click on the link to jump from one page to another page.

Examples

This example demonstrates how to create a link in an HTML document.
This example demonstrates how to use the image as a link.

HTML hyperlinks (links)

Hyperlinks can be a word, a word, or a group of words, it can be an image, you can click on the contents to jump to a new document or a section in the current document.

When you move the mouse pointer to a link on a Web page, the arrow becomes a little hand.

We create links in HTML by using <a> label.

There are two ways to use <a> label:

  1. By using the href attribute - create a link to another document link
  2. By using the name attribute - create bookmarks within the document

HTML link syntax

Link HTML code is very simple. It is something like this:

<a href="url">Link text</a>

href attribute specifies the destination of the link.

Text between the start and end tags to be displayed as hyperlinks.

Examples

<a href="http://www.w3school.com.cn/">Visit W3School</a>

Click on the hyperlink takes the user to W3School home.

Tip: "link text" is not necessarily a text. Images or other HTML elements can be a link.

HTML links - target property

Use the Target property, you can define the linked document is displayed where.

The line below will open the document in a new window:

<a href="http://www.w3school.com.cn/" target="_blank">Visit W3School!</a>

HTML links - name attribute

name attribute specifies the name of the anchor (anchor) is.

You can create bookmarks in an HTML page using the name attribute.

Bookmarks are not displayed in any special way, it is not visible to the reader.

When using named anchors (named anchors), we can create a direct jump to the named anchor (such as a page in the section) link, so users do not need to constantly scroll the page to find the information they need.

Named anchor syntax:

<a name= "label"> anchor (display text on the page) </a>

Tip: anchor name can be any name you like.

Tip: You can use the id attribute to replace the name attribute, named anchor equally effective.

Examples

First of all, we have to be named anchor in HTML documents (create a bookmark):

<a>name="tips" Basic Notes - Useful Tips </a>

We then create a link pointing to the anchor in the same document:

<a href="#tips"> useful tips </a>

You can also create links to the anchor links to other pages:

<a href="http://www.w3school.com.cn/html/html_links.asp#tips"> useful tips </a>

In the above code, we'll add a # sign and the name of the anchor to the end of the URL, you can link directly to this named anchor the tips.

Basic precautions - useful tips:

Note: Always add a forward slash to subfolder. If this link Writing: href = "http://www.w3school.com.cn/html", will produce two HTTP requests to the server. This is because the server will add a slash to the address, and then create a new request like this: href = "http://www.w3school.com.cn/html/".

Tip: Named anchors are often used to create a directory in a large document starting position. A named anchor can be given for each chapter, and then link to these link anchor into the upper part of the document. If you frequently visit Baidu Encyclopedia, you will notice that almost every entry adopt such navigation.

Tip: If your browser can not find a named anchor has been defined, it will locate to the top of the document. No error occurred

Guess you like

Origin www.cnblogs.com/fighter007/p/11351643.html