The HTMLSourceElement
interface provides special properties (beyond the regular HTMLElement
object interface it also has available to it by inheritance) for manipulating <source>
elements.
HTMLSourceElement
Properties
Inherits properties from its parent, HTMLElement
.
-
HTMLSourceElement.media
-
Is a
DOMString
reflecting themedia
HTML attribute, containing the intended type of the media resource. -
HTMLSourceElement.sizes
Experimental -
Is a
DOMString
representing image sizes between breakpoints -
HTMLSourceElement.src
-
Is a
DOMString
reflecting thesrc
HTML attribute, containing the URL for the media resource. TheHTMLSourceElement.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 parentHTMLMediaElement
'sload
method should be called when done, since<source>
elements are not re-scanned automatically. -
HTMLSourceElement.srcset
Experimental -
Is a
DOMString
reflecting thesrcset
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 thetype
HTML attribute, containing the type of the media resource.
Methods
No specific method; inherits methods from its parent, HTMLElement
.
Specifications
Specification |
---|
HTML Standard # htmlsourceelement |
Browser compatibility
Desktop | Mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | WebView Android | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | |
HTMLSourceElement |
1
|
12
|
3.5
|
9
|
≤12.1
|
3.1
|
≤37
|
18
|
4
|
≤12.1
|
2
|
1.0
|
height |
90
|
90
|
No
|
No
|
76
|
15
|
90
|
90
|
No
|
64
|
15
|
15.0
|
media |
1
|
12
|
3.5
|
9
|
≤12.1
|
3.1
|
≤37
|
18
|
4
|
≤12.1
|
2
|
1.0
|
sizes |
36
|
13
|
38
|
No
|
23
|
10.1
|
37
|
36
|
38
|
24
|
10.3
|
3.0
|
src |
1
|
12
|
3.5
|
9
|
≤12.1
|
3.1
|
≤37
|
18
|
4
|
≤12.1
|
2
|
1.0
|
srcset |
38
|
13
|
38
|
No
|
25
|
10.1
|
38
|
38
|
38
|
25
|
10.3
|
3.0
|
type |
1
|
12
|
3.5
|
9
|
≤12.1
|
3.1
|
≤37
|
18
|
4
|
≤12.1
|
2
|
1.0
|
width |
90
|
90
|
No
|
No
|
76
|
15
|
90
|
90
|
No
|
64
|
15
|
15.0
|
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
.
© 2005–2021 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement