a标签中href="#xxx"跳到id="xxx"

HTML中a标签中href="#xxx",当点击后,页面会跳转到标签中id="xxx"的地方。
同时,在URL上的后面会看到加上了#xxx,这样直接改变URL中#后面的值,然后页面就可以跳转到标签中id为这个值的地方。
 
测试代码:
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
<style>
p{
    height:700px;
}
</style>
</head>
<body>
    <a href="#xxx">tab1</a>
    <a href="#b">tab2</a>
    <a href="#c">tab3</a>

    <p>pp<em>pppp</em>pp</p>
    <h2 id="xxx">tag1</h2>
    <p>111111111</p>
    <h2 id="b">tag2</h2>
    <p>111111111</p>
    <h2 id="c">tag3</h2>
    <p>111111111</p>
</body>
</html>
原文地址:https://www.cnblogs.com/ayguo/p/4059630.html