Web/API/HTMLSourceElement

From Get docs


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.media
Is a DOMString reflecting the media HTML attribute, containing the intended type of the media resource.
HTMLSourceElement.sizes '
Is a DOMString representing image sizes between breakpoints
HTMLSourceElement.src
Is a DOMString 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. 

Note: If the 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 '
Is a 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.type
Is a DOMString reflecting the type HTML attribute, containing the type of the media resource.

Methods

No specific method; inherits methods from its parent, HTMLElement.

Specifications

Specification Status Comment
HTML Living StandardThe definition of 'HTMLSourceElement' in that specification. Living Standard

Browser compatibility

Update compatibility data on GitHub

Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
HTMLSourceElement Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 3.5

IE

Full support 9

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 4

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

keySystem

Experimental'Deprecated'Non-standard'

Chrome

Full support Yes

Edge

Full support ≤18

Firefox Full support Yes

Disabled'

Full support Yes

Disabled'

Disabled' This feature is behind the media.eme.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

IE

?

Opera

?

Safari

?

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android Full support Yes

Disabled'

Full support Yes

Disabled'

Disabled' This feature is behind the media.eme.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

Opera Android

?

Safari iOS

?

Samsung Internet Android

Full support Yes

media Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 3.5

IE

Full support 9

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 4

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

sizes

Experimental'

Chrome

Full support Yes

Edge

Full support 13

Firefox Full support 38


Full support 38


Full support 33

Disabled'

Disabled' From version 33: this feature is behind the dom.image.picture.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

IE

No support No

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android Full support 38


Full support 38


Full support 33

Disabled'

Disabled' From version 33: this feature is behind the dom.image.picture.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

Opera Android

?

Safari iOS

?

Samsung Internet Android

Full support Yes

src Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 3.5

IE

Full support 9

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 4

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

srcset

Experimental'

Chrome

Full support Yes

Edge

Full support 13

Firefox Full support 38


Full support 38


Full support 33

Disabled'

Disabled' From version 33: this feature is behind the dom.image.picture.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

IE

No support No

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android Full support 38


Full support 38


Full support 33

Disabled'

Disabled' From version 33: this feature is behind the dom.image.picture.enabled preference (needs to be set to true). To change preferences in Firefox, visit about:config.

Opera Android

?

Safari iOS

?

Samsung Internet Android

Full support Yes

type Chrome

Full support Yes

Edge

Full support 12

Firefox

Full support 3.5

IE

Full support 9

Opera

Full support Yes

Safari

Full support Yes

WebView Android

Full support Yes

Chrome Android

Full support Yes

Firefox Android

Full support 4

Opera Android

Full support Yes

Safari iOS

Full support Yes

Samsung Internet Android

Full support Yes

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.'
Experimental. Expect behavior to change in the future.
Non-standard. Expect poor cross-browser support.'
Non-standard. Expect poor cross-browser support.
Deprecated. Not for use in new websites.'
Deprecated. Not for use in new websites.
User must explicitly enable this feature.'
User must explicitly enable this feature.


See also