Home >Web Front-end >HTML Tutorial >How to make anchor links

How to make anchor links

不言
不言Original
2018-12-27 13:49:4537171browse

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>

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>

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!

Statement:
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