<w> smolweb

audio: The Embed Audio element

The <audio> HTML element is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the <source> element: the browser will choose the most suitable one. It can also be the destination for streamed media, using a MediaStream.

Attributes

Specific attributes

Required attributes

src="[URL]" specifies 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 in one or multiple formats/qualities.

Recommended attributes

controls 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.

Allowed attributes

loop if specified, the audio player will automatically seek back to the start upon reaching the end of the audio.

muted indicates whether the audio will be initially silenced. Its default value is false.

Global attributes

accesskey Specifies a keyboard shortcut to activate or focus an element.

aria-* Defines accessibility properties and states for assistive technologies.

class Specifies one or more CSS class names for styling the element.

data-* Stores custom data private to the page or application.

dir Sets the text direction (left-to-right, right-to-left, or auto).

hidden Hides the element from display and assistive technologies.

id Defines a unique identifier for the element within the document.

inputmode Hints which virtual keyboard type to display on mobile devices.

itemid Provides a global identifier for microdata items.

itemprop Defines a property name-value pair for microdata.

itemref Associates properties with an item via element IDs for microdata.

itemscope Creates a new microdata item container.

itemtype Specifies the vocabulary URL for microdata items (like Schema.org).

lang Specifies the primary language of the element’s content.

nonce Provides a cryptographic nonce for Content Security Policy.

role Defines the element’s semantic role for accessibility.

tabindex Controls keyboard navigation order and focusability.

title Provides advisory information displayed as a tooltip.

Example

<audio controls>
  <source src="media/myAudio.mp3" type="audio/mpeg">
  <source src="media/myAudio.ogg" type="audio/ogg">
  <p>
    Download <a href="media/myAudio.mp3" download="myAudio.mp3">MP3</a> or
    <a href="media/myAudio.ogg" download="myAudio.ogg">OGG</a> audio file.
  </p>
</audio>