Html5 anchor & lt; a & gt; page Jump, name = abc herf = # abc,

Source: Internet
Author: User

Html5 anchor <a> page Jump, name = abc herf = # abc,

<A name = "top"> here is the TOP part </a>

<A href = "# top"> click my link to TOP </a>

<A name = "content"> CONTENT </a>

<A href = "# content"> click my link to CONTENT </a>

<A name = "foot"> here is the FOOT part </a>

<A href = "# foot"> click my link to FOOT </a>

(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 the hyperlink label <a> </a> to create an anchor link, which is mainly used for access by the anchor in the page.

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:
<A href = "#001"> jump to 001 </a>
... Text omitted
<A name = "001" id = "001"> </a>
... 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 <a> </a> value of our anchor is empty, we can add a space to ensure the beauty of the anchor,

Use the following code to be compatible with ie8:
<A href = "#001"> jump to 001 </a>
... Text omitted
<A name = "001" id = "001"> & n B s p </a>
... 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:
<A href = "123.html #001"> skip to 001 </a>
... Text omitted
<A name = "001" id = "001"> & n B s p </a>
... 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 have "? "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 <a> (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. After the link is opened, the test code uses <a href = "# C4"> and <a name = "C4">. The test is normal. Change "
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 <a> label is # and the value of the Target name or id is added to the beginning:

The Code is as follows:


<Html>
<Body>
<P>
<A href = "# method1"> method 1 </a>
</P>
<P>
<A href = "# method2"> method 2 of page anchor </a>
</P>
<H2> <a name = "method1"> method 1 </a> <P> use the href and name attributes of the anchor tag </p>
<H2 id = "method2"> method 2 <P> use the anchor tag and id attribute </p>
</Body>
</Html>

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.