English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Reference

HTML: <audio> src Attribute

The src attribute specifies the location of the audio file (URL), to make it work in all browsers- Use the <source> element within the <audio> element. The <source> element can link to different audio files. Browsers will use the first recognized format.

HTML <audio> tag

Online Example

Play Audio:

<!DOCTYPE html>
<html>
<title>HTML:<audio> src Attribute - Basic Tutorial Website oldtoolbag.com</title>
<body>
<audio src="horse.ogg" controls>
Your browser does not support the audio element.
</audio>
</body>
</html>
Test and see ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

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

Note: IE and Safari do not support the .ogg file format.

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

Definition and Usage

The src attribute specifies the location of the audio file (URL).
The example above uses Ogg format audio files and will run in Firefox, Opera, and Chrome.
To play audio files in Internet Explorer and Safari, we must use MP3file.
to work in all browsers- within the <audio> element<source>Element. The <source> element can link to different audio files. Browsers will use the first recognized format.

Online Example

<!DOCTYPE html>
<html>
<title>HTML:<audio> src Attribute - Basic Tutorial Website oldtoolbag.com</title>
<body>
<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
  Your browser does not support the audio tag.
</audio>
</body>
</html>
Test and see ‹/›

HTML 4.01 compared to HTML5differences

The <audio> tag is part of HTML5Newly added.

Syntax

<audio src="URL">

Attribute value

ValueDescription
URL

Specifies audio/URL of the video source.

Possible values:

  • Absolute URL - points to another website (for example src="http://example.com/movie.ogg")

  • Relative URL - points to a file within the website (for example src="/data/movie.ogg")

HTML <audio> tag