GO-Ve01
ServicesDevelopersBooksDictionaryPapersWikidataEncyclopediaSearchBabelCareersDeck

HTMLSourceElement

HTML DOM

HTML DOM

The **`HTMLSourceElement`** interface provides special properties (beyond the regular HTMLElement object interface it also has available to it by inheritance) for manipulating source elements.

## Instance properties

_Inherits properties from its parent, HTMLElement._

- HTMLSourceElement.height
- : A number that reflects the [`height`](/docs/Web/HTML/Reference/Elements/source#height) HTML 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.media
- : A string reflecting the [`media`](/docs/Web/HTML/Reference/Elements/source#media) HTML attribute, containing the intended type of the media resource.
- HTMLSourceElement.sizes
- : A string representing image sizes between breakpoints
- HTMLSourceElement.src
- : A string reflecting the [`src`](/docs/Web/HTML/Reference/Elements/source#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
- : A string reflecting the [`srcset`](/docs/Web/HTML/Reference/Elements/source#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
- : A string reflecting the [`type`](/docs/Web/HTML/Reference/Elements/source#type) HTML attribute, containing the type of the media resource.
- HTMLSourceElement.width
- : A number that reflects the [`width`](/docs/Web/HTML/Reference/Elements/source#width) HTML 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

## 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.

source: MDN Web Docs mirror · page

Cite this

"HTMLSourceElement". MDN Web Docs. CC BY-SA 2.5 (MDN). https://developer.mozilla.org/en-US/docs/Web/API/HTMLSourceElement

JSON record · API collection · BibTeX · RIS · CSL-JSON · citation policy

Save to pass ·