HTMLSourceElement: type property

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.

The type property of the HTMLSourceElement interface is a string representing the MIME type of the media resource.

It reflects the type attribute of the <source> element.

Value

A string.

Examples

html
<video>
  <source
    id="el"
    src="large.webp"
    type="video/webp"
    media="screen and (width >= 600px)" />
</video>
js
const el = document.getElementById("el");
console.log(el.type); // Output: "video/webp"

Specifications

Specification
HTML
# dom-source-type

Browser compatibility

See also