Introduction to using the anchor (named anchor) in an html webpage _ HTML/Xhtml _ webpage Creation

Source: Internet
Author: User
The anchor in html must be familiar to everyone. Anchor is a kind of super-level link in the production of web pages, also known as the name of anchor. The following describes how to use the anchor in an instance, don't miss out on friends you don't know. Organize the following information from the Internet:

1. the anchor is a kind of super-level links in the production of web pages. It is also called the name anchor.. Like a rapid locator, named anchor is a hyperlink in a page and is widely used.
English name: anchor
You can use named anchor to set tags in the document, which are usually placed at or top of a specific topic of the document. You can then create these named anchor links that can quickly take visitors to a specified location.
The process of creating a link to the named anchor is divided into two steps. First, create a named anchor and then create a link to the named anchor.

Sample Code

Define the following anchor in an appropriate location on the HTML page:
Here is the TOP part
Here is the CONTENT section
Here is the FOOT part
(You can use the id attribute to replace the name attribute. The named anchor is also valid. [1])
You can use either of the following methods to access the source object:
One is to use a hyperlink label to create an anchor link, which is mainly used for access by the anchor in the page.
Click my link to TOP
Click my link to CONTENT
Click my link to FOOT
The other method is to add an anchor mark directly behind the page address, which is mainly used for access by anchor points between different pages.
If the address of this page is http: // file path/index.html, you only need to access the following link to access the foot anchor.
Http: // file path/index.html # foot

2. What is the html anchor?
To put it simply, for example, a long article, you can use the anchor if you want to accurately read data by segment.

Code:
Jump to 001
... Text omitted

... Text omitted

In fact, only the name of the anchor can be used, and the id is added to make it more compatible.
The href value must be consistent with name \ I d. "#" must be added before. The above code can be compatible in ie6, 7, and ff, but cannot be used in ie8.
Because the value of our anchor is empty, we can just add a space to ensure the beauty is not affected,

Use the following code to be compatible with ie8:
Jump to 001
... Text omitted
& N B s p
... Text omitted

Another question is, how can I display the content of an anchor on a page (such as 123.html?

The Code is as follows:
Jump to 001
... Text omitted
& N B s p
... Text omitted

This was when I was working on the background yesterday and wanted to "Modify the positioning", I moved the anchor mark out (I usually forget it ).
But the program says they want a value, and the connection must contain "?" Or "&", so my anchor is not compatible...
Haha! There will be solutions in the future!
Although there is a problem with anchor compatibility in jsp pages, there is no problem in static pages and it is worth learning!

3. In WEB development, the page anchor is used.. HTML page anchor is used to link to a section of a page. As mentioned in W3School, creating an anchor uses the (Anchor) label and name attribute, but this is not the only way to create a page anchor. The following describes how to create an HTML page anchor.

We can use W3School's online testing tool for testing. The test code after the link is opened uses sum, and the test is normal. Change "Chapter 4" to "Chapter 4" and then perform the test. The results are the same.

Note: in addition to the name attribute of the anchor tag, you can also use the id attribute to create a page anchor. The value of the href attribute in the anchor tag is # and the value of the Target name or id is added at the beginning:

The Code is as follows:





Method 1



Method 2


Method 1

Use the href and name attributes of the anchor tag


Method 2

Use the anchor tag and id attribute



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.