Media & Embedded Content

HTML <audio> Tag

The <audio> tag is used to embed sound content in a document, such as music or other audio streams.

Definition and Usage

The <audio> tag is used to embed sound content in a document, such as music or other audio streams.

Standard Syntax:<audio>...</audio>

Interactive ExampleRunnable

HTML <audio> Example

html
Try it Yourself
Live code demonstration for the <audio> tag. Click "Try it Yourself" to edit and experiment in real time.
<div style="font-family: system-ui, sans-serif; padding: 16px; background: #ffffff; border-radius: 8px; border: 1px solid #e2e8f0; color: #0f172a;">
<audio controls>

  <source src="horse.ogg" type="audio/ogg">

  <source src="horse.mp3" type="audio/mpeg">

  Your browser does not support the audio tag.

 </audio>
</div>

Attributes for <audio>

6 Supported Attributes
AttributeValuesDefaultDescription
autoplayautoplaynoneSpecifies that the audio will start playing as soon as it is ready
controlscontrolsnoneSpecifies that audio controls should be displayed (such as a play/pause button etc)
looploopnoneSpecifies that the audio will start over again, every time it is finished
mutedmutednoneSpecifies that the audio output should be muted
preloadauto metadata nonenoneSpecifies if and how the author thinks the audio should be loaded when the page loads
srcURLnoneSpecifies the URL of the audio file
Global Attributes

The <audio> tag also supports the standard global attributes in HTML, including class, id, style, title, hidden, and data-*.

HTML Global Attributes Reference →
Event Attributes

The <audio> tag supports event attributes in HTML, such as onclick, onmouseover, onfocus, and more.

HTML Event Attributes Reference →

Browser Compatibility

ChromeEdgeFirefoxSafariOpera

More Tags in Media & Embedded Content

View All 123Tags →