HTML 超链接
2025-04-23
17
参考资料
HTML 超链接
基本标签
<a>
标签用于创建超链接
主要属性
href
: 指定链接目标URLtarget
: 控制链接打开方式_self
: 当前窗口(默认)_blank
: 新窗口_parent
: 父框架_top
: 顶层框架rel
: 定义链接与当前文档的关系nofollow
: 告诉搜索引擎不要追踪noopener
: 防止新窗口访问原窗口noreferrer
: 隐藏来源信息
基本用法
<a href="https://example.com">示例链接</a> <a href="page.html" target="_blank">新窗口打开</a> <a href="#section-id">页面锚点</a>
功能扩展
邮件链接
<a href="mailto:contact@example.com">发送邮件</a>
电话链接
<a href="tel:+1234567890">拨打电话</a>
下载链接
<a href="file.pdf" download>下载PDF</a>
CSS 扩展样式
/* 基础样式 */ a { color: #0066cc; text-decoration: none; } /* 悬停效果 */ a:hover { text-decoration: underline; color: #004499; } /* 访问过的链接 */ a:visited { color: #660099; } /* 活动状态(点击时) */ a:active { color: #cc0000; } /* 按钮样式链接 */ a.button { display: inline-block; padding: 10px 15px; background-color: #0066cc; color: white; border-radius: 4px; transition: background-color 0.3s; } a.button:hover { background-color: #004499; }
高级用法
链接预加载
<link rel="prefetch" href="page.html">
链接预连接
<link rel="preconnect" href="https://example.com">
链接预加载资源
<link rel="preload" href="font.woff2" as="font">
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。