How to Embed Audio on a Website

The best method depends on where the file is hosted and how much control you need. Here are the three common options and when to use each.

Use the audio element for your own files

This is the lightest option and gives you full control of the file and page. Upload the file to your own server or storage and point the player at it:

<audio controls preload="metadata">
  <source src="/media/track.mp3" type="audio/mpeg">
</audio>

Good for: music samples, short clips and sites that want no third-party code. Read the full audio element guide.

Use an iframe from a podcast or streaming host

Hosted players are easy to paste into a page and often include statistics, but they add third-party code and may set cookies. Most podcast and music hosts offer an “Embed” or “Share” button that gives you the code.

Good for: podcasts and tracks already published on another platform. Check whether the host’s cookies need to be mentioned in your privacy policy.

Use the WordPress Audio block

In WordPress, add an Audio block and upload a file or choose one from the Media Library. No extra plugin is needed for a basic player. For playlists or advanced players, see our guide to adding an audio player in WordPress.

Quick comparison

MethodSetupControlThird-party code
Audio elementEasyFullNone
Hosted iframeVery easyLimitedYes
WordPress Audio blockVery easyBasicNone

Tips for any method

  • Do not start sound automatically.
  • Keep files small so pages stay fast. See how to optimize audio files.
  • Offer a transcript or download link for spoken content.