We're looking for a person or people to help audit MDN to find places we could speed up. Is this you or someone you know? Check out the RFP: https://mzl.la/2IHcMiE

To tłumaczenie jest niekompletne. Pomóż przetłumaczyć ten artykuł z języka angielskiego.

Element HTML <audio> jest używany do osadzania w dokumencie treści dźwiękowych. Może zawierać jedno lub kilka źródeł audio reprezentowanych poprzez użycie atrybutu src lub elementu <source>: dana przeglądarka wybierze najbardziej odpowiedni dla niej zapis. Poprzez użycie MediaStream znacznik może służyć również jako destynacja dla mediów strumieniowych.

Kategorie treści Ogólna treści dokumentu, treść syntagmatyczna, treść osadzona. Jeśli posiada atrybut controls: treść interaktywna i odczuwalna.
Treści dozwolone Jeśli element posiada atrybut src: element <track> zero lub wyższy, po którym następuje treść transparentna nie zawierająca elementów mediów, czyli <audio> i <video>.
Inaczej: element <source> zero lub wyższy, po którym następuje element <track> zero lub wyższy, po którym następuje z kolei treść transparenta nie zawierająca elementów mediów, czyli <audio> i <video>.
Pominięcie tagu None, both the starting and ending tag are mandatory.
Dozwoleni rodzice Każdy element akceptujący treść osadzoną.
Dozwolone role ARIA application
Interfejs DOM HTMLAudioElement


This element's attributes include the global attributes.

A Boolean attribute: if specified (even if the value is "false"!), the audio will automatically begin playback as soon as it can do so, without waiting for the entire audio file to finish downloading.
Sites which automatically play audio (or videos with an audio track) can be an unpleasant experience for users, so it should be avoided when possible. If you must offer autoplay functionality, you should make it opt-in (requiring a user to specifically enable it). However, this can be useful when creating media elements whose source will be set at a later time, under user control.
autobuffer Przestarzały Gecko 2.0
A Boolean attribute: if specified, the audio will automatically begin being downloaded, even if not set to autoplay. This continues until the media cache is full, or the entire audio file has been downloaded, whichever comes first. This should only be used when it is expected that the user will choose to play the audio; for example, if the user has navigated to a page using a "Play this audio" link. This attribute was removed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1) in favor of the preload attribute.
An attribute you can read to determine which time ranges of the media have been buffered. This attribute contains a TimeRanges object.
If this attribute is present, the browser will offer controls to allow the user to control audio playback, including volume, seeking, and pause/resume playback.
A Boolean attribute: if specified, will automatically seek back to the start upon reaching the end of the audio.
The offset, specified as the number of samples since the beginning of the audio stream, at which the audio is currently playing.
A Boolean attribute which indicates whether the audio will be initially silenced. Its default value is false.
A TimeRanges object indicating all the ranges of the audio that have been played.
This enumerated attribute is intended to provide a hint to the browser about what the author thinks will lead to the best user experience. It may have one of the following values:
  • none: indicates that the audio should not be preloaded;
  • metadata: indicates that only audio metadata (e.g. length) is fetched;
  • auto: indicates that the whole audio file could be downloaded, even if the user is not expected to use it;
  • the empty string: synonym of the auto value.

If not set, its default value is browser-defined (i.e. each browser may have its own default value). The spec advises it to be set to metadata.

Usage notes:
  • The autoplay attribute has precedence over preload. If autoplay is specified, the browser would obviously need to start downloading the audio for playback.
  • The browser is not forced by the specification to follow the value of this attribute; it is a mere hint.
The URL of the audio to embed. This is subject to HTTP access controls. This is optional; you may instead use the <source> element within the audio block to specify the audio to embed.
The playback volume, in the range 0.0 (silent) to 1.0 (loudest).

Time offsets are specified as float values indicating the number of seconds to offset.

Note: The time offset value definition has not yet been completed in the HTML5 specification and is subject to change.


An audio element can fire various events.

Usage notes

Fallback content for browsers not supporting the <audio> element can be added inside the opening and closing <audio></audio> tags.

The most basic playback functionality can be made available using the controls attribute (see below); for more advanced usage, audio playback and controls can be manipulated using the HTML Media API, and more specifically the features defined in the HTMLAudioElement interface.

You can also use the Web Audio API to directly generate and manipulate audio streams from JavaScript code. See Web Audio API for details.


Basic usage

<!-- Simple audio playback -->
  Your browser does not support the <code>audio</code> element.

<!-- Audio playback with captions -->
<audio src="foo.ogg">
  <track kind="captions" src="foo.en.vtt" srclang="en" label="English">
  <track kind="captions" src="foo.sv.vtt" srclang="sv" label="Svenska">

Audio element with source element

<audio controls="controls">
  Your browser does not support the <code>audio</code> element.
  <source src="foo.wav" type="audio/wav">


Specification Status Comment
HTML Living Standard
The definition of '<audio>' in that specification.
Living Standard  
The definition of '<audio>' in that specification.

Browser compatibility

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 3.0 (Yes) 3.5 (1.9.1) [1] 9.0 10.5 3.1
autoplay attribute 3.0 (Yes) 3.5 (1.9.1) 9.0 10.5 3.1
buffered attribute ? (Yes) 4.0 (2.0) ? ? ?
controls attribute 3.0 (Yes) 3.5 (1.9.1) 9.0 10.5 3.1
loop attribute 3.0 (Yes) 11.0 (11.0) 9.0 10.5 3.1
muted attribute ? (Yes) 11.0 (11.0) ? ? ?
played property ? (Yes) 15.0 (15.0) ? ? ?
preload attribute 3.0 (Yes) 4.0 (2.0) 9.0 (Yes) [2] 3.1
src attribute 3.0 (Yes) 3.5 (1.9.1) 9.0 10.5 3.1
volume attribute   (Yes)        
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support ? (Yes) 1.0 (1.0) [1] ? ? ?
autoplay attribute ? (Yes) 1.0 (1.0) ? ? ?
buffered attribute ? (Yes) 4.0 (2.0) ? ? ?
controls attribute ? (Yes) 1.0 (1.0) ? ? ?
loop attribute ? (Yes) 11.0 (11.0) ? ? ?
muted attribute ? (Yes) 11.0 (11.0) ? ? ?
played property ? (Yes) 15.0 (15.0) ? ? ?
preload attribute ? (Yes) 4.0 (2.0) ? ? ?
src attribute ? (Yes) 1.0 (1.0) ? ? ?
volume attribute   (Yes)        

[1] For Gecko to play audio, the server must serve the file using the correct MIME type.

[2] Supported under the older name autobuffer

See also

Autorzy i etykiety dokumentu

 Autorzy tej strony: drm404
 Ostatnia aktualizacja: drm404,