HTMLSourceElement
TheHTMLSourceElement interface provides special properties (beyond the regularHTMLElement object interface it also has available to it by inheritance) for manipulating<source> elements.
In this article
Instance properties
Inherits properties from its parent,HTMLElement.
HTMLSourceElement.heightA number that reflects the
heightHTML attribute, indicating the height of the image resource in CSS pixels. The property has a meaning only if the parent of the current<source>element is a<picture>element.HTMLSourceElement.mediaA string reflecting the
mediaHTML attribute, containing the intended type of the media resource.HTMLSourceElement.sizesA string representing image sizes between breakpoints
HTMLSourceElement.srcA string reflecting the
srcHTML 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.Note:If the
srcproperty is updated (along with any siblings), the parentHTMLMediaElement'sloadmethod should be called when done, since<source>elements are not re-scanned automatically.HTMLSourceElement.srcsetA string reflecting the
srcsetHTML 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.typeA string reflecting the
typeHTML attribute, containing the type of the media resource.HTMLSourceElement.widthA number that reflects the
widthHTML attribute, indicating the width of the image resource in CSS pixels. The property has a meaning only if the parent of the current<source>element is a<picture>element.
Instance methods
No specific method; inherits methods from its parent,HTMLElement.
Specifications
| Specification |
|---|
| HTML> # htmlsourceelement> |
Browser compatibility
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.