How to make anchor links

不言
Release: 2018-12-27 13:49:45
Original
37166 people have browsed it

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.

How to make 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&#39;m here!</a>
</body>
</html>
Copy after login

The running effect is as follows

How to make anchor links

When you click "Jump", it will jump to "hello, I'm here" !", the effect is as follows

How to make anchor links

# 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&#39;m here!</a>
</body>
</html>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template