HTML <audio> srcAttribute

HTML audio 标签参考手册HTML <audio> Tag

Example

Play audio:

<audio src="horse.ogg.html" controls>
Your browser does not support the audio element.
</audio>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Internet Explorer 9+, Firefox, Opera, Chrome, and Safari browsers all support the src attribute. However, not all browsers support all audio file formats.

Note:Internet Explorer 8 and earlier IE versions do not support the <audio> tag.


Definition and Usage

The src attribute describes the address (URL) of the audio file.

Audio in Ogg file format can be played in Firefox, Opera, and Chrome browsers.

If you need to play audio in Internet Explorer and Safari browsers, you must use an MP3 file.

To be compatible with all browsers - use the <source> element inside the <audio> element.<source>The <source> element can link to different audio files. The browser will use the first recognized audio file format.

Example

<audio controls>
  <source src="horse.ogg.html" type="audio/ogg">
  <source src="horse.mp3.html" type="audio/mpeg">
Your browser does not support the audio element.
</audio>

Try it Yourself »


Difference between HTML 4.01 and HTML5

The <audio> tag is new in HTML5.


Syntax

<audio src="URL.html">

Attribute Value

Value Description
URL

Specifies the URL of the audio/video source.

Possible values:

  • Absolute URL - points to another website (e.g. src="http://example.com/movie.ogg")
  • Relative URL - points to a file within the website (e.g. src="../data/movie.ogg.html")


HTML audio 标签参考手册HTML <audio> Tag

Other Extensions