GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • MDN
  • HTML: Markup language
  • Elements
  • Global attributes
  • Attributes
  • See all…
  • Responsive images
  • HTML cheatsheet
  • Date & time formats
  • See all…
  • SVG
  • MathML
  • XML
  • CSS: Styling language

This view

  • Original page
  • New address

GeezerVison is showing developer.mozilla.org — HTMLSourceElement - Web APIs | MDN

HTMLSourceElement

Baseline
Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

  • See full compatibility
  • Learn more

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 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 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 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 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 HTML attribute, containing the type of the media resource.

HTMLSourceElement.width

A number that reflects the 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

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.

Help improve MDN

Learn how to contribute

This page was last modified on Jun 23, 2025 by MDN contributors.

View this page on GitHub • Report a problem with this content
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.