HTMLLinkElement: type 属性

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

HTMLLinkElement 接口的 type 属性是一个字符串,表示链接资源的 MIME 类型

它反映了 <link> 元素的 type 属性。

一个字符串,必须是有效的 MIME 类型字符串。

示例

html
<link
  id="el"
  rel="apple-touch-icon"
  sizes="114x114"
  href="apple-icon-114.png"
  type="image/png" />
js
const el = document.getElementById("el");
console.log(el.type); // Output: "image/png"

规范

规范
HTML
# dom-link-type

浏览器兼容性