The HTMLSourceElement interface provides special properties (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating <source> elements.
Properties
Inherits properties from its parent, HTMLElement.
- HTMLSourceElement.keySystem
- Is a DOMStringdescribing the key system encrypting the stream.
- HTMLSourceElement.media
- Is a DOMStringreflecting themediaHTML attribute, containing the intended type of the media resource.
- HTMLSourceElement.sizes
- Is a DOMString
- HTMLSourceElement.src
- Is a DOMStringreflecting thesrcHTML attribute, containing the URL for the media resource. TheHTMLSourceElement.srcproperty 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.
- HTMLSourceElement.srcset
- Is a DOMStringreflecting thesrcsetHTML 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.type
- Is a DOMStringreflecting thetypeHTML attribute, containing the type of the media resource.
Methods
No specific method; inherits methods from its parent, HTMLElement.
Specifications
| Specification | Status | Comment | 
|---|---|---|
| Encrypted Media Extensions The definition of 'HTMLSourceElement' in that specification. | Working Draft | Added the keySystemattribute. | 
| WHATWG HTML Living Standard The definition of 'HTMLSourceElement' in that specification. | Living Standard | No change from HTML5. | 
| HTML5 The definition of 'HTMLSourceElement' in that specification. | Recommendation | Initial definition. | 
Browser compatibility
| Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) | 
|---|---|---|---|---|---|
| Basic support | (Yes) | 3.5 (1.9.1) | (Yes) | (Yes) | (Yes) | 
| srcsetattribute | ? | 33 (33)[1] | ? | ? | ? | 
| sizesattribute | ? | 33 (33)[1] | ? | ? | ? | 
| keySystemattribute | ? | (Yes)[2] | ? | ? | ? | 
| Feature | Android | Firefox Mobile (Gecko) | IE Phone | Opera Mobile | Safari Mobile | 
|---|---|---|---|---|---|
| Basic support | (Yes) | 1.0 (1.9.1) | (Yes) | (Yes) | (Yes) | 
| srcsetattribute | ? | 33.0 (33)[1] | ? | ? | ? | 
| sizesattribute | ? | 33.0 (33)[1] | ? | ? | ? | 
| keySystemattribute | ? | (Yes)[2] | ? | ? | ? | 
[1] Gecko implements this behind the preference dom.image.picture.enabled, defaulting to false.
[2] Gecko implements this behind the preference media.eme.enabled, defaulting to false.
See also
- The HTML element implementing this interface: <source>.
- The HTML DOM APIs of the elements that can contain a <source>element:HTMLVideoElement,HTMLAudioElement,HTMLPictureElement.