HTMLSourceElement: media property

فهرست فصل‌ها دانلود آرشیوناشر

MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونه‌کد

{{APIRef("HTML DOM")}}

The **media** property of the {{domxref("HTMLSourceElement")}} interface is a string representing the intended destination medium for the resource. The value is a media query, which is a comma separated list of media-types, media-features, and logical operators.

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

Value

A string.

Examples

html
<video>
  <source
    id="el"
    src="largeVideo.mov"
    type="video/quicktime"
    media="screen and (width >= 600px)" />
</video>
js
const el = document.getElementById("el");
console.log(el.media); // Output: "screen and (width >= 600px)"
el.media = "(width >= 800px)"; // Updates the media value

Specifications

{{Specifications}}

Browser compatibility

{{Compat}}

See also

  • {{domxref("HTMLSourceElement.type")}}
  • {{domxref("HTMLSourceElement.sizes")}}
  • {{domxref("HTMLSourceElement.src")}}
  • {{domxref("HTMLSourceElement.srcset")}}
  • {{htmlelement("source")}}
  • {{htmlelement("picture")}}
  • {{htmlelement("audio")}}
  • {{htmlelement("video")}}
  • Using media queries