HTML CSS Bootstrap Javascript Icons Python
HTML References
HTML - Tag Reference HTML - Tag by Category HTML - Attributes HTML - Global Attributes HTML - Events HTML - Language Codes HTML - Country Codes HTML - URL Encoding HTTP Methods HTTP Status Codes <input> types
All HTML Tags
<!-- --> <!DOCTYPE> <a> <abbr> <acronym> <address> <applet> <area> <article> <aside> <audio> <b> <base> <basefont> <bdi> <bdo> <big> <blockquote> <body> <br> <button> <canvas> <caption> <center> <cite> <code> <col> <colgroup> <data> <datalist> <dd> <del> <details> <dfn> <dialog> <dir> <div> <dl> <dt> <em> <embed> <fieldset> <figcaption> <figure> <font> <footer> <form> <frame> <frameset> <h1> - <h6> <head> <header> <hr> <html> <i> <iframe> <img> <input> <ins> <kbd> <label> <legend> <li> <link> <main> <map> <mark> <meta> <meter> <nav> <noframes> <noscript> <object> <ol> <optgroup> <option> <output> <p> <param> <picture> <pre> <progress> <q> <rp> <rt> <ruby> <s> <samp> <script> <section> <select> <small> <source> <span> <strike> <strong> <style> <sub> <summary> <sup> <svg> <table> <tbody> <td> <template> <textarea> <tfoot> <th> <thead> <time> <title> <tr> <track> <tt> <u> <ul> <var> <video> <wbr>

HTML <source> tag

The HTML <source> element specifies multiple media resources for the <picture>, the <audio> element, or the <video> element.

The <source> element is an empty element which means that it has no end tag.

It is commonly used to serve the same media content in multiple formats supported by different browsers.

Run code

Browser compatibility

The numbers in the table specify the first browser version that fully supports the <source> element:

<source> 4 3.5 10.5 4 9


The following table shows the attributes that are specific to the <source> tag:

Attribute Value Description
src URL Defines the URL of the resource. Required when <source> is used in <audio> or <video>
srcset URL Defines the URL of the image to use in different situations. Required when <source> is used in <picture>
media media_query Media query of the resource's intended media; this should be used only in a <picture> element
type MIME-type Specifies the MIME-type of the resource

Global Attributes

The <source> tag supports the global attributes described in HTML Global Attributes Reference

Event Attributes

The <source> tag supports the event attributes described in HTML Events Reference

More Examples

This example specifies a picture element with two source files, and a fallback image:

Run code

Last updated: Friday 28 Sep, 2018