HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

HTML Tutorial

HTML Basics

Introduction to HTMLHTML EditorsHTML StructureHTML Elements & AttributesHTML HeadingsHTML ParagraphsHTML FormattingHTML CommentsHTML Styles

HTML Text and Links

HTML Text FormattingHTML Quotations & CitationsHTML LinksHTML Email Links

HTML Lists and Tables

HTML ListsHTML TablesTable Styling & Borders

HTML Images and Media

HTML ImagesHTML Picture ElementHTML AudioHTML VideoHTML Embed & Object

HTML Forms

HTML Forms OverviewHTML Form ElementsHTML Input TypesHTML Input AttributesHTML Form AttributesHTML Form Validation

HTML Layout

HTML Block vs Inline ElementsHTML Div & SpanHTML Semantic Layout TagsHTML Iframes

Advanced HTML

HTML Entities & SymbolsHTML EmojisHTML Head Element TagsHTML Meta Tags for SEOHTML Responsive Design

HTML References

HTML5 New TagsDeprecated TagsHTML Global AttributesEvent AttributesComplete HTML Tag ListComplete HTML5 ElementsHTML Tutorial PDF
  1. Home
  2. /
  3. Tutorials
  4. /
  5. HTML Tutorial
  6. /
  7. HTML Audio

HTML Images and Media

HTML Audio

HTML allows you to add audio content directly to web pages using the <audio> element. You can embed music, podcasts, sound effects, or any audio file without relying on third-party plugins. The <audio> element supports multiple audio formats, offers controls, and can play automatically or loop based on your settings.

HTML <audio> Syntax

Audio Example

html

<audio controls>
  <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg">
  <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>

Explanation

  • <audio>: The container element for audio files.
  • controls: Adds play, pause, volume, and other standard audio controls.
  • <source>: Specifies the audio file and its type. Multiple sources ensure compatibility across browsers.
  • Fallback text: Displayed if the browser doesn’t support the <audio> element.

Attributes of <audio>

  • controls: Shows audio player controls.
  • autoplay: Starts playing automatically when the page loads.
  • loop: Replays audio continuously.
  • muted: Starts audio in a muted state.
  • preload: Specifies whether to load audio data (auto, metadata, none).

Example with attributes:

HTML Audio Attributes

html

<audio controls autoplay loop>
  <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg">
  Your browser does not support the audio element.
</audio>

Supported Audio Formats

  1. MP3 - widely supported.
  2. OGG - open-source alternative.
  3. WAV - uncompressed audio, large file size.

⚠️ Tip: Always provide multiple formats for maximum browser compatibility.

Example: Complete HTML Audio Player

Complete HTML Audio Example

html

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>HTML Audio Example</title>
</head>
<body>

<h2>Listen to Our Audio Track</h2>
<audio controls>
  <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.mp3" type="audio/mpeg">
  <source src="https://www.soundhelix.com/examples/mp3/SoundHelix-Song-1.ogg" type="audio/ogg">
  Your browser does not support the audio element.
</audio>

<p>Enjoy the music directly from your browser without any plugins!</p>

</body>
</html>

Advantages

  • Embed audio without third-party plugins.
  • Cross-browser compatibility with multiple source formats.
  • Easy to control playback with attributes like autoplay, loop, and controls.
  • Improves interactivity and engagement on web pages.

Browser Support

Chrome
Edge
Firefox
Safari
Opera
IE9+
YesYesYesYesYesPartially

Conclusion

The HTML <audio> element makes adding sound to your website simple and efficient.
By using multiple sources and the built-in controls, you can ensure your audio plays seamlessly across all modern browsers. Whether it’s background music, podcasts, or alerts, <audio> enhances the user experience without extra plugins.

PreviousHTML Picture ElementNextHTML Video