Dofactory.com
Dofactory.com
Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

HTML <source> type Attribute

The type attribute on a <source> tag specifies the media type of the source file.

A media type indicates the format and nature of the file.

Example

#

Two <source> elements with a type attribute. The type value specifies the media type (formerly MIME type) of the video files.

<video width="320" height="240" controls>
  <source type="video/mp4" src="/media/movie.mp4">
  <source type="video/ogg" src="/media/movie.ogg">
</video>

Using type

A media type, formerly known as a MIME type, indicates the format and nature of a file.

Browsers don't look at a file extension, but rather what media type it is.

A list with common media types is available on this site.

Tip:   The IANA organization maintains a full list of official media types.


Common media types

There are hundreds of media types.
These are some common types that are used on the web.

Media Type Description
text/html HTML
image/png PNG
application/pdf PDF
application/vnd.ms-excel Excel
text/csv Comma Separated Values
video/mp4 MP4

Tip:  Check our HTTP Media Types Reference for a more complete list of common media types.


Syntax

<source type="media-type">

Values

#

Value Description
media-type The media type of the source file.

Browser support

Here is when type support started for each browser:

Chrome
4.0 Jan 2010
Firefox
3.5 Jun 2009
IE/Edge
9.0 Mar 2011
Opera
10.5 Mar 2010
Safari
4.0 Jun 2009

You may also like

 Back to <source>

Last updated on Sep 30, 2023

Earn income with your HTML skills
Sign up and we'll send you the best freelance opportunities straight to your inbox.
We're building the largest freelancing marketplace for people like you.
By adding your name & email you agree to our terms, privacy and cookie policies.

Guides