分享建站教程、云服务器、HTML技术和ZBlog模板
HTML 超链接用 `<a>` 标签来创建,最核心的属性是 `href`,用来指定链接跳转的地址。

基础语法:
```html
<a href="https://www.baidu.com">百度一下</a>
```
🔗 常用代码示例
1. 文本链接:点击文字跳转
```html
<a href="https://www.example.com">访问示例网站</a>
```
2. 新窗口打开:加 `target="_blank"`
```html
<a href="https://www.example.com" target="_blank">在新标签页打开</a>
```
3. 图片链接:用 `<a>` 包住 `<img>`
```html
<a href="https://www.example.com">
<img src="图片地址.jpg" alt="图片描述">
</a>
```
4. 锚点链接:页面内跳转到指定位置
```html
<!-- 先给目标位置加个 id -->
<h2 id="section1">第一部分</h2>
<!-- 再创建跳转链接 -->
<a href="section1">跳转到第一部分</a>
```
5. 邮箱链接:点击唤起邮件客户端
```html
<a href="mailto:example@example.com">发邮件给我</a>
```
6. 下载链接:加 `download` 属性
```html
<a href="file.zip" download="新文件名.zip">下载文件</a>
```
7. 空链接:占位用,点击不会跳转
```html
<a href="">暂无链接</a>
```
几个注意点
- `href` 可以是相对路径(如 `about.html`)或绝对路径(完整网址)
- 用 `title` 属性可以加悬停提示文字,比如 `<a href="..." title="提示内容">`
- 想给链接改样式(颜色、下划线等),需要用 CSS 控制
- 邮箱链接里如果主题或正文有特殊字符,要做 URL 编码,比如空格用 `%20`
来源:站长网,转载请保留出处和链接!
本文链接:https://www.htmlit.com.cn/post/12.html
本文标签:HTML超链接
Copyright 2026 站长网 ┊ Powered by:Z-Blog 苏ICP备2024145453号-3