HTML Audio Last Updated : 26 Dec, 2024 Comments Improve Suggest changes Like Article Like Report The HTML <audio> element is used to add audio content to a webpage, allowing you to play music, sound effects, or other audio files directly in the browser.Syntax<audio> <source src="sample.mp3" type="audio/mpeg"></audio>. HTML <!DOCTYPE html> <html lang="en"> <body> <audio> <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20241009180552641558/sample-12s.mp3" type="audio/mp3"> <source src="" type="audio/ogg"> </audio> </body> </html> The <audio> supports the global attributes and event attributes.Functionality of HTML AudioThe controls attribute adds play, pause, and volume controls to the audio player.The autoplay attribute makes the audio play automatically when the page loads.The loop attribute makes the audio play continuously, repeating the file.The src attribute defines the URL of the audio file.The muted attribute silences the audio when the page loads.HTML Audio Media TypesThe mp3 file format with media type audio/mpeg.The ogg file format with media type audio/ogg.The wav file format with media type audio/wav.More Examples of HTML AudioBasic Autoplay Audio HTML <html lang="en"> <body> <audio autoplay> <source src="https://media.geeksforgeeks.org/wp-content/uploads/20241009180552641558/sample-12s.mp3" type="audio/mpeg"> </audio> </body> </html> The <audio> element includes the autoplay attribute, causing the audio to play automatically upon page load.The <source> element specifies the audio file's URL and its MIME type.To learn more about the HTML audio autoplay attribute, click here Link Autoplay Audio with Controls and Styling HTML <!DOCTYPE html> <html lang="en"> <head> <style> audio { display: block; margin: 20px auto; width: 80%; } </style> </head> <body> <audio controls autoplay> <source src= "https://media.geeksforgeeks.org/wp-content/uploads/20241009180552641558/sample-12s.mp3" type="audio/mpeg"> </audio> </body> </html> The <audio> element includes both controls and autoplay attributes, providing playback controls to the user while starting the audio automatically.The CSS styles center the audio player on the page and set its width to 80% of the container, enhancing its appearance.Best Practices for HTML AudioProvide multiple audio formats to ensure compatibility across different browsers.Include the controls attribute to offer users playback options like play, pause, and volume control. Comment More infoAdvertise with us Next Article HTML Audio S shivanigupta18rk Follow Improve Article Tags : HTML HTML5 Similar Reads HTML Tutorial HTML stands for HyperText Markup Language. It is the standard language used to create and structure content on the web. It tells the web browser how to display text, links, images, and other forms of multimedia on a webpage. HTML sets up the basic structure of a website, and then CSS and JavaScript 11 min read HTML Interview Questions and Answers HTML (HyperText Markup Language) is the foundational language for creating web pages and web applications. Whether you're a fresher or an experienced professional, preparing for an HTML interview requires a solid understanding of both basic and advanced concepts. Below is a curated list of 50+ HTML 14 min read Top 10 Projects For Beginners To Practice HTML and CSS Skills Learning to code is an exciting journey, especially when stepping into the world of programming with HTML and CSSâthe foundation of every website you see today. For most beginners, these two building blocks are the perfect starting point to explore the creative side of web development, designing vis 8 min read HTML Introduction HTML stands for Hyper Text Markup Language, which is the core language used to structure content on the web. It organizes text, images, links, and media using tags and elements that browsers can interpret. As of 2025, over 95% of websites rely on HTML alongside CSS and JavaScript, making it a fundam 6 min read HTML Tags - A to Z List HTML Tags are fundamental elements used to structure and format content on web pages. They provide instructions to web browsers on how to render text, images, links, and other media.HTML tags are enclosed in angle brackets < > and usually come in pairs: an opening tag and a closing tag. The cl 15+ min read HTML DOCTYPE Declaration HTML DOCTYPE (Document Type Declaration) is an instruction that appears at the beginning of an HTML document, before the <html> tag.Its primary role is to tell the web browser which version of HTML the page is written in, ensuring that the browser renders the content correctly. It is not an HT 4 min read 30+ Web Development Projects with Source Code [2025] Web development is one of the most in-demand career paths in the IT industry, experiencing consistent growth of around 20â25% annually. Whether you're a student starting out or an experienced professional looking to switch or advance your career, it's essential to go beyond theory and demonstrate yo 4 min read Frontend Developer Interview Questions and Answers Frontend development is an important part of web applications, and it is used to build dynamic and user-friendly web applications with an interactive user interface (UI). Many companies are hiring skilled Frontend developers with expertise in HTML, CSS, JavaScript, and modern frameworks and librarie 15+ min read HTML Forms HTML forms, defined using the <form> Tags are essential for collecting user input on web pages. They incorporate a variety of interactive controls such as text fields, numeric inputs, email fields, password fields, checkboxes, radio buttons, and submit buttons. Over 85% of websites rely on for 5 min read HTML Tables HTML (HyperText Markup Language) is the standard markup language used to create and structure web pages. It defines the layout of a webpage using elements and tags, allowing for the display of text, images, links, and multimedia content. As the foundation of nearly all websites, HTML is used in over 10 min read Like