Technical Notes

Audio Element Attributes

βœ… <audio> element β€” all standard attributes:

Attribute
Type
Description

src

URL

URL of the audio file (optional if <source> used)

controls

Boolean

Shows browser’s built-in audio controls

autoplay

Boolean

Starts playing automatically when loaded

loop

Boolean

Restarts playback when audio ends

muted

Boolean

Starts playback muted

preload

Enum

Hints to browser about preloading: none, metadata, or auto

crossorigin

Enum

Controls CORS: anonymous or use-credentials

playsinline

Boolean

(iOS Safari) Prevents fullscreen when audio is played

disableRemotePlayback

Boolean

Prevents casting to remote playback devices

class, id, style, title, etc.

Global attributes

Standard HTML global attributes


βœ… <source> element β€” all standard attributes:

Attribute
Type
Description

src

URL

URL of the media file

type

MIME

Media type (e.g., audio/mpeg, audio/ogg)

media

Media query

Optional: apply only if media query matches

sizes

(unused in audio/video)

Mostly relevant for <img> in srcset

srcset

(unused in audio/video)

Not applicable for <audio> or <video>


Notes:

  • <audio> may use src directly or contain multiple <source> elements.

  • <source> elements allow fallbacks and are used in sequence.

  • Boolean attributes are true if present, false if omitted.

Blank src

Yes, a <source> element with no src will be safely ignored by all major browsers during media selection.

Behavior:

  • The browser processes <source> elements in order.

  • If a <source> has no src, it is skipped, even if type is valid.

  • This is defined in the HTML spec: the src attribute is required; if missing or empty, the source is considered invalid and ignored.

Example:

This is safe and will not cause errors or warnings in any standards-compliant browser.

Last updated