The HTMLSourceElement interface provides special properties (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating <source> elements.
Inherits properties from its parent, HTMLElement.
HTMLSourceElement.keySystem
DOMString describing the key system encrypting the stream.HTMLSourceElement.mediaDOMString reflecting the media HTML attribute, containing the intended type of the media resource.HTMLSourceElement.sizes
DOMString representing image sizes between breakpointsHTMLSourceElement.srcDOMString reflecting the src HTML attribute, containing the URL for the media resource. The HTMLSourceElement.src property has a meaning only when the associated <source> element is nested in a media element that is a <video> or an <audio> element. It has no meaning and is ignored when it is nested in a <picture> element. src property is updated (along with any siblings), the parent HTMLMediaElement's load method should be called when done, since <source> elements are not re-scanned automatically.HTMLSourceElement.srcset
DOMString reflecting the srcset HTML attribute, containing a list of candidate images, separated by a comma (',', U+002C COMMA). A candidate image is a URL followed by a 'w' with the width of the images, or an 'x' followed by the pixel density.HTMLSourceElement.typeDOMString reflecting the type HTML attribute, containing the type of the media resource.No specific method; inherits methods from its parent, HTMLElement.
| Specification | Status | Comment |
|---|---|---|
| Encrypted Media Extensions The definition of 'HTMLSourceElement' in that specification. | Recommendation | Added the keySystem attribute. |
| HTML Living Standard The definition of 'HTMLSourceElement' in that specification. | Living Standard | |
| HTML5 The definition of 'HTMLSourceElement' in that specification. | Recommendation | Initial definition. |
| Desktop | ||||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
| Basic support | Yes | Yes | 3.5 | 9 | Yes | Yes |
keySystem
|
Yes | Yes | Yes
|
? | ? | ? |
media |
Yes | Yes | 3.5 | 9 | Yes | Yes |
sizes
|
Yes | Yes | 38
|
? | ? | ? |
src |
Yes | Yes | 3.5 | 9 | Yes | Yes |
srcset
|
Yes | Yes | 38
|
? | ? | ? |
type |
Yes | Yes | 3.5 | 9 | Yes | Yes |
| Mobile | |||||||
|---|---|---|---|---|---|---|---|
| Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
| Basic support | Yes | Yes | Yes | 4 | Yes | Yes | ? |
keySystem
|
Yes | Yes | Yes | Yes
|
? | ? | ? |
media |
Yes | Yes | Yes | 4 | Yes | Yes | ? |
sizes
|
Yes | Yes | Yes | 38
|
? | ? | ? |
src |
Yes | Yes | Yes | 4 | Yes | Yes | ? |
srcset
|
Yes | Yes | Yes | 38
|
? | ? | ? |
type |
Yes | Yes | Yes | 4 | Yes | Yes | ? |
<source>.<source> element: HTMLVideoElement, HTMLAudioElement, HTMLPictureElement.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement