01 / 12

How can we embed audio in HTML?

Embedding Audio in HTML

In HTML, the <audio> element is used to embed audio files directly into a web page. It allows users to play sounds like music, voice recordings, or effects without requiring external plugins.

Key Points about <audio>
  1. 1

    The <audio> tag supports attributes like controls, autoplay, loop, and muted.

  2. 2

    Common formats supported are MP3, OGG, and WAV.

  3. 3

    The <source> tag inside <audio> allows providing multiple file formats for better browser compatibility.

  4. 4

    If the browser doesn’t support the <audio> element, fallback text can be displayed.

Example Usage

In short: The <audio> element lets you embed and control sound playback directly in your web pages.