When there is too much content on the web page, we can use anchor links to jump to the location. Through anchor links, we can not only point to the document, but also to specific paragraphs on the page, which will make it easier for us to browse the content on the web page. , then, how to implement anchor links? This article will introduce to you how to implement anchor links.
Method 1: Use id for anchor positioning
Let’s look at a specific example
The code is as follows
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <a href="#string">跳转</a> <hr/> <br><br><br><br><br> <br><br><br><br>< <br><br><br> <br><br> <br><br> <br><br> <br> <br> <br> <a id="string">hello,I'm here!</a> </body> </html>
The running effect is as follows
When you click "Jump", it will jump to "hello, I'm here" !", the effect is as follows
# will jump to "hello, I'm here!" on the current page.
Method 2: Use the name attribute to implement anchor links
Let’s see a specific example
The code is as follows
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> </head> <body> <a href="#string">跳转</a> <hr/> <br><br><br><br><br> <br><br><br><br>< <br><br><br> <br><br> <br><br> <br><br> <br> <br> <br> <a name="string">hello,I'm here!</a> </body> </html>
Also when the mouse clicks "Jump", it will jump to "hello, I'm here!" on the current page.
The above is the detailed content of How to make anchor links. For more information, please follow other related articles on the PHP Chinese website!