--- id: bad88fee1348bd9aedf08816 title: 用 a 实现网页内部跳转 challengeType: 0 videoUrl: 'https://scrimba.com/p/pVMPUv/cyrDRUL' forumTopicId: 301098 dashedName: link-to-internal-sections-of-a-page-with-anchor-elements --- # --description-- `a`(*anchor*)元素也可以用于创建内部链接,跳转到网页内的各个不同部分。 要创建内部链接,你需要将链接的 `href` 属性值设置为一个哈希符号 `#` 加上你想内部链接到的元素的 `id`,通常是在网页下方的元素。 然后你需要将相同的 `id` 属性添加到你链接到的元素中。 `id` 是描述网页元素的一个属性,它的值在整个页面中唯一。 当用户点击了 `Contacts` 链接,页面就会跳转到网页的 **Contacts** 区域。 ```html Contacts ...

Contacts

``` 当用户点击 `Contacts` 链接,可以访问网页中带有 **Contacts** 标题元素的部分。 # --instructions-- 通过修改 `href` 属性值为 `"#footer"`,同时修改文本 `cat photos` 为 `Jump to Bottom`,来更改外部链接为内部链接。 然后添加一个 `