Home > Web Front-end > HTML Tutorial > Anchors and page jumps in html

Anchors and page jumps in html

yulia
Release: 2018-09-10 15:48:15
Original
2207 people have browsed it

1. Setting the anchor point for intra-page jump
Jumping within the page requires two steps:
Method 1:
①: Set an anchor linkGo find cats; (Note: Add # at the beginning of the attribute value of the href attribute)
②: Set the anchor point at the required position on the page (Note: A name attribute must be written in the a tag, and the attribute value must be the same as the href attribute value in ①, without adding #) Fill in the necessary text in the tag as needed, Generally do not write content
Method 2:
①: Same as method 1①
②: Set the location of the anchor point

Meow Star Base

Add an id attribute to the label of the position you want to jump to. The attribute value is the same as the href attribute value in ①, without adding
#. Method 2 does not need to add a separate a tag to specifically set the anchor point, only in the required position. Just add an id to the tag.

Small case:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>萌宠集结号</title>
</head>
<body>
<ul>
<li><a href="#miao">去找喵星人</a></li>
<li><a href="#wang">去找汪星人</a></li>
<li><a href="#meng">其他萌物</a></li>
</ul>
<a name="miao"></a><!--设置锚点方法1-->
<h3 id="miao">喵星人基地</h3><!--设置锚点方法2-->
<p>喵喵喵~</p>
<p>喵喵喵~</p>
<p>喵喵喵~</p>
<p>喵喵喵~</p>
<p>喵喵喵~</p>
<p>喵喵喵~</p>
<a name="wang"></a>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<p>汪汪汪~</p>
<a name="meng"></a>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
<p>萌萌萌~</p>
</body>
</html>
Copy after login

2. Cross-page jump

①: Set the anchor link and append after the path in href: # Anchor name, you can
such as: Jump to the Cute Pet Collection Account page
②: To jump to To set the anchor point on the page, please see step ② for the method. Choose one of the two methods.

The above is the detailed content of Anchors and page jumps in html. 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