English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
HTML5 provides standards for playing audio files.
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.
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.
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
Currently, the <audio> element supports three audio format files: MP3, Wav, and Ogg:
Browser | MP3 | Wav | Ogg |
Internet Explorer 9+ | YES | NO | NO |
Chrome 6+ | YES | YES | YES |
Firefox 3.6+ | YES | YES | YES |
Safari 5+ | YES | YES | NO |
Opera 10+ | YES | YES | YES |
Format | MIME-type |
MP3 | audio/mpeg |
Ogg | audio/ogg |
Wav | audio/wav |
Tag | Description |
<audio> | Defined the audio content |
<source> | Specifies multimedia resources, which can be multiple, between <video> and Used in the <audio> tag |