此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

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 ⁨2015年7月⁩.

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

浏览器兼容性

参见