HTMLLinkElement:rel 属性
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
HTMLLinkElement
接口的 rel
属性反映 rel
属性。它是一个字符串,包含由空格分隔的链接类型列表,这些类型指示由 <link>
元素表示的资源与当前文档之间的关系。
此属性最常见的用途是指定一个外部样式表的链接:将属性设置为 stylesheet
,并将 href
属性设置为外部样式表的 URL,以便格式化页面。
值
一个字符串。
示例
js
const links = document.getElementsByTagName("link");
for (const link of links) {
console.log(link);
}
规范
Specification |
---|
HTML # dom-link-rel |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
rel |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
参见
- 在
<a>
和<area>
元素上对应的属性是HTMLAnchorElement.rel
和HTMLAreaElement.rel
。 - 相同的列表,但以标记形式表示:
HTMLLinkElement.relList