Menu
×
   ❮     
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS R TYPESCRIPT ANGULAR GIT POSTGRESQL MONGODB ASP AI GO KOTLIN SASS VUE DSA GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE
     ❯   

HTML <link> 标签


示例

链接到外部样式表

<head>
  <link rel="stylesheet" href="styles.css">
</head>
亲自试一试 »

定义和用法

The <link> 标签定义当前文档与外部资源之间的关系。

The <link> 标签最常用于链接到外部样式表或在您的网站上添加 favicon

The <link> 元素是一个空元素,它只包含属性。


浏览器支持

元素
<link>


属性

属性 描述
crossorigin anonymous
use-credentials
指定元素如何处理跨域请求
href URL 指定链接文档的位置
hreflang language_code 指定链接文档中文本的语言
media media_query 指定将在什么设备上显示链接文档
referrerpolicy no-referrer
no-referrer-when-downgrade
origin
origin-when-cross-origin
unsafe-url
指定获取资源时使用哪个推荐者
rel alternate
author
dns-prefetch
help
icon
license
next
pingback
preconnect
prefetch
preload
prerender
prev
search
stylesheet
必需。指定当前文档与链接文档之间的关系
sizes 高度x宽度
any
指定链接资源的大小。仅适用于 rel="icon"
title   定义首选或备用样式表
type media_type 指定链接文档的媒体类型

全局属性

The <link> 标签还支持 HTML 中的全局属性


事件属性

The <link> 标签还支持 HTML 中的事件属性


相关页面

HTML 教程:HTML 样式

HTML DOM 参考:链接对象


默认 CSS 设置

大多数浏览器将使用以下默认值显示 <link> 元素

link {
  display: none;
}

×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.

Copyright 1999-2024 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.