link 标签用于定义文档和外部资源之间的链接。 link 标签用于链接到外部样式表。这个元素可以出现多次,但它只出现在头部部分。
link 元素是空的,它只包含属性。
句法:
属性:
Value | Description |
---|---|
charset | It assigns the character encoding of the linked document |
crossOrigin | It assigns the CORS settings of the linked document |
disabled | It assigns whether the linked document is disabled, or not |
href | It is used to set/return the URL of the linked document |
hreflang | It assigns the language code of the linked document |
media | It assigns the media type for the link element |
rel | It assigns the relationship between the current document and the linked document |
rev | It assigns the reverse relationship from the linked document to the current document |
sizes | Returns the sizes attribute’s value of the linked resource |
type | It is used to set/return the content type of the linked document |
示例: HTML
HTML Link Tag
GeeksforGeeks
HTML Link Tag
CSS:
h1 {
color: green;
}
h1, h2{
text-align: center;
}
输出:
支持的浏览器: HTML 标签支持的浏览器如下:
- 谷歌浏览器
- IE浏览器
- 火狐
- 苹果Safari
- 歌剧