Source type attribute

Definition and usage

type Set or return the value of the type attribute in the <source> element.

source type attribute Define the MIME type of media resources.

See also:

HTML Reference Manual:HTML <source> Tag

Example

Return the MIME type of media resources:

var x = document.getElementById("mySource").type;

Try it yourself

Syntax

Return type attribute:

sourceObject.type

Set type attribute:

sourceObject.type = MIME_type

Attribute value

Value Description
MIME_type

Define the MIME type of media resources.

Common MIME types:

For video:

  • video/ogg
  • video/mp4
  • video/webm

For audio:

  • audio/ogg
  • audio/mpeg

Please see IANA MIME Types, to get a complete list of standard MIME types.

Technical Details

Return Value: A string value representing the MIME type of the media resource.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related Pages

HTML Reference Manual:HTML <source> type Attribute