English name: anchor
Use named anchors to set marks in a document, which are usually placed at or at the top of a specific topic in the document. Links to these named anchors can then be created that quickly bring visitors to a specified location.
The process of creating a link to a named anchor is divided into two steps. First, create a named anchor, and then create a link to that named anchor.
Sample codeDefine the following anchor points in the HTML page at the appropriate location:
<a name=top>Here is the TOP part</a>
<a name=content>Here is the CONTENT part</a>
<a name=foot>This is the FOOT part</a>
(You can use the id attribute instead of the name attribute, and named anchors are also valid. [1])
There are two ways to access the anchor point as above
One is to use the hyperlink tag <a></a> to create anchor links, which are mainly used for anchor access in the page.
<a href=#top>Click me to link to TOP</a>
<a href=#content>Click me to link to CONTENT</a>
<a href=#foot>Click me to link to FOOT</a>
Another way is to directly add anchor marks after the page address, which is mainly used for anchor point access between different pages.
If the address of this page is http://file path/index.html, to access the foot anchor, just access the following link.
http://file path/index.html#foot
2.What exactly does html anchor do?In simple terms, for example, if you want to look at a very long article in precise paragraphs, you can use the anchor point.
Code:
<a href=#001>Skip to 001</a>
...Text omitted
<a name=001 id=001 >/a>
...Text omitted
In fact, the anchor point only needs name, and the id is added to make it more compatible.
The value of href must be consistent with name/id, and # must be added before it. The above code is compatible in ie6/7 and ff, but it cannot be done in ie8.
Because the value of our anchor point is empty, we just need to add a space to not affect the beauty.
As the following code, it can be compatible with ie8
<a href=#001>Skip to 001</a>
...Text omitted
<a name=001 id=001 > & nbsp </a>
...Text omitted
Another question, what about displaying the content of an anchor point on a certain 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 > & nbsp </a>
...Text omitted
This was yesterday when I was working in the background. I wanted to modify the positioning, so I moved the anchor mark out (I usually forget it).
But the program says that they want to get the value, and they must have a ? or & in the connection, so that my anchor points will be incompatible...
hehe! There will be a solution in the future!
Although there are problems with anchor compatibility in jsp pages, there is no problem in static pages and it is still worth learning!
3. In WEB development, page anchors will be used . HTML page anchors are used to link to a chapter of a page. W3School says that creating anchors uses the <a> (anchor) tag and name attribute, but this is not the only way to create a page anchor. Let’s briefly talk about two ways to make HTML page anchors.We can use W3School's online testing tool to test. The test code after opening the link uses <a href=#C4″> and <a name=C4″>, and there is no problem with the test. Then change <h2> <a name=C4″>Chapter 4 </a> </h2> to <h2 id=C4″>Chapter 4 </h2> and then test, the effect is the same.
Note: In addition to using the anchor tag name attribute, you can also use the id attribute for creating page anchors. The value of the href attribute in the anchor point <a> tag is the value of the starting point # plus the target's name or id:
Copy the code