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.
A string.
<source id="el" src="large.webp" type="video/webp" media="screen and (width >= 600px)" />
const el = document.getElementById("el");
console.log(el.type); // Output: "video/webp"
| Specification |
|---|
| HTML> # dom-source-type> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
type |
3 | 12 | 3.5 | ≤12.1 | 3.1 | 18 | 4 | ≤12.1 | 2 | 1.0 | 4.4 | 2 |
HTMLSourceElement.srcHTMLSourceElement.srcsetHTMLSourceElement.mediaHTMLSourceElement.sizes<source><picture><audio><video>
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement/type