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

HTML5 Audio (Audio)

HTML5 provides standards for playing audio files.

Audio on the Internet

Until now, there is still no standard aimed at playing audio on the web.

Today, most audio is played through plugins (such as Flash). However, not all browsers have the same plugins.

HTML5 specifies the standard for embedding audio elements on web pages, that is, using the <audio> element.

Browser Support

Internet Explorer 9+, Firefox, Opera, Chrome, and Safari all support the <audio> element.

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

HTML5 Audio - How it works

If you want to play audio in HTML5 To play audio in the middle, you need to use the following code:

!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>Basic Tutorial(oldtoolbag.com)</title> 
</head>
<body>
<audio controls>
  <source src="horse.ogg" type="audio/ogg">
  <source src="horse.mp3" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</body>
</html>
test and see ‹/›

the control attribute is provided for adding play, pause, and volume controls.

in <audio> and </You need to insert the prompt text for the <audio> element that the browser does not support between >.

<audio> elements allow the use of multiple <source> elements. <source> elements can link to different audio files, and the browser will use the first supported audio file

Audio Format and Browser Support

Currently, the <audio> element supports three audio format files: MP3, Wav, and Ogg:

BrowserMP3WavOgg
Internet Explorer 9+YESNONO
Chrome 6+YESYESYES
Firefox 3.6+YESYESYES
Safari 5+YESYESNO
Opera 10+YESYESYES

MIME types for audio formats

FormatMIME-type
MP3audio/mpeg
Oggaudio/ogg
Wavaudio/wav

HTML5 Audio Tag

TagDescription
<audio>Defined the audio content
<source>Specifies multimedia resources, which can be multiple, between <video> and Used in the <audio> tag