English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The HTML <audio> element is used to represent audio content in a document. The <audio> element can contain multiple audio resources, which can be described using the src attribute or the <source> element; the browser will choose the most appropriate one to use. For browsers that do not support the <audio> element, the <audio> element can also be added to the document as content that the browser does not recognize.
Play sound:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Basic Tutorial Website (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 to see <‹/›
IEFirefoxOperaChromeSafari
IE 9+, Firefox, Opera, Chrome and Safari all support the <audio> tag.
Note: IE 8 and earlier versions of IE browsers do not support the <audio> tag.
The <audio> tag defines sound, such as music or other audio streams.
At the moment, the <audio> element supports 3 file formats: MP3, WAV and OGG.
Browser | MP3 | Wav | Ogg |
---|---|---|---|
Internet Explorer | SÌ | NO | NO |
Chrome | SÌ | SÌ | SÌ |
Firefox | SÌ | SÌ | SÌ |
Safari | SÌ | SÌ | NO |
Opera | SÌ | SÌ | SÌ |
L'etichetta <audio> è una nuova etichetta in HTML5.
Attenzione:Qualsiasi testo tra <audio> e </audio> viene visualizzato nei browser che non supportano l'etichetta <audio>.
New: Proprietà nuove in HTML5.
Proprietà | Valore | Descrizione |
---|---|---|
autoplayHTML5 | autoplay | Se presente, l'audio viene riprodotto immediatamente dopo che è pronto. |
controlsHTML5 | controls | Se presente, viene visualizzato il controllo audio dell'utente (ad esempio, pulsante play/pausa). |
loopHTML5 | loop | Se presente, l'audio viene riprodotto ogni volta che termina. |
mutedHTML5 | muted | Se presente, l'output audio è silenzioso. |
preloadHTML5 | auto metadata none | Stabilisce se l'audio viene caricato per impostazione predefinita e come viene caricato quando la pagina web viene caricata. |
srcHTML5 | URL | Stabilisce l'URL del file audio. |
Supporto <audio> etichetta Proprietà globali HTML.
Supporto <audio> etichetta Proprietà degli eventi HTML.