Back to Content

HTMLLinkElement: media property

files/en-us/web/api/htmllinkelement/media/index.md

latest687 B
Original Source

{{APIRef("HTML DOM")}}

The media property of the {{domxref("HTMLLinkElement")}} interface is a string representing a list of one or more media formats to which the resource applies.

It reflects the media attribute of the {{HTMLElement("link")}} element.

Value

A string.

Examples

html
<link
  id="el"
  href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css"
  rel="stylesheet"
  media="screen and (width >= 600px)"
  crossorigin="anonymous" />
js
const el = document.getElementById("el");
console.log(el.media); // Output: "screen and (width >= 600px)"

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}