English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
O elemento <audio> do HTML é usado para representar conteúdo de áudio em documentos. O elemento <audio> pode conter múltiplos recursos de áudio,que podem ser descritos usando a propriedade src ou o elemento <source>;o navegador escolherá o mais apropriado para usar. Para navegadores que não suportam o elemento <audio>,o elemento <audio> também pode ser adicionado ao documento como conteúdo não reconhecido pelo navegador.
Reprodução de som:
!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Site de Tutoriais Básicos (oldtoolbag.com)</title> </head> <body> <audio controls> <source src="horse.ogg" type="audio/ogg"> <source src="horse.mp3" type="audio/mpeg"> Seu navegador não suporta o elemento audio. </audio> </body> </html>Teste e veja ‹/›
IEFirefoxOperaChromeSafari
IE 9+、Firefox、Opera、Chrome e Safari todos suportam a tag <audio>.
Notas: IE 8 ou versões mais antigas do navegador IE não suportam a tag <audio>.
A tag <audio> define sons,por exemplo,música ou outros fluxos de áudio。
Atualmente,o elemento <audio> suporta3formatos de arquivo: MP3,WAV e Ogg。
navegador | MP3 | Wav | Ogg |
---|---|---|---|
Internet Explorer | YES | NO | NO |
Chrome | YES | YES | YES |
Firefox | YES | YES | YES |
Safari | YES | YES | NO |
Opera | YES | YES | YES |
The <audio> tag is a part of HTML5New tag in
Note:and </ Any text between <audio> and <
New: HTML5 New attribute in
Attribute | Value | Description |
---|---|---|
autoplayHTML5 | autoplay | If this attribute is present, the audio is played immediately after it is ready. |
controlsHTML5 | controls | If this attribute is present, the audio control is displayed to the user (for example, play/Pause button). |
loopHTML5 | loop | If this attribute is present, the audio is replayed every time it ends. |
mutedHTML5 | muted | If this attribute is present, the audio output is silent. |
preloadHTML5 | auto metadata none | Specifies whether the audio is loaded by default when the web page is loaded and how it is loaded. |
srcHTML5 | URL | Specifies the URL of the audio file. |
Support for <audio> tag Global attributes of HTML.
Support for <audio> tag HTML event attributes.