---
title: "Audio element in HTML5"  
description: "HTML5 introduced new element . This element specifies audio file on html document. By using this element user can listen audio file.HTML5 specifies a"  
author: "Anonymous User"  
published: 2011-07-21  
updated: 2020-03-04  
canonical: https://www.mindstick.com/articles/576/audio-element-in-html5  
category: "html5"  
tags: ["html5"]  
reading_time: 2 minutes  

---

# Audio element in HTML5

[HTML5](https://www.mindstick.com/articles/1535/offline-add-edit-delete-data-in-html5-indexeddb) introduced new element <audio>. This element specifies audio file on html document. By using this element user can listen audio file.HTML5 specifies a [standard](https://www.mindstick.com/articles/23223/naming-convention-or-coding-standard) way to add audio file on [web page](https://answers.mindstick.com/qa/92898/how-to-create-a-web-page-using-bootstrap-4) with the help of audio element. <audio> element [support](https://yourviews.mindstick.com/view/81072/pakistan-wants-enmity-not-support-from-india-during-coronavirus-pandemic) three format of audio\

1. **Ogg Vorbis** : This format is supported by firefox3.5 or later, opera10.5 or later and [google](https://yourviews.mindstick.com/story/1191/top-products-and-services-from-google) chrome [3.0](https://yourviews.mindstick.com/view/81146/lockdown-3-0-leading-to-open-alocholism) browser.
2. **MP3**: This format will be supported by IE9, google chrome3.0 and safari3.0 or later.
3. **Wav**: This format is supported by firefox3.5 or later, opera10.5 or later and safari 3.0 or later.

##### Syntax to use Audio element in html5

<audio src="source-file [location](https://www.mindstick.com/news/2574/twitter-conveniently-reveals-a-location-sharing-policy-amid-elonjet-controversy)" [controls](https://www.mindstick.com/articles/66/how-to-create-controls-at-run-time-in-csharp-dot-net)="controls">

</audio>

##### Audio element properties

- **src**: In this [attribute](https://www.mindstick.com/blog/61/ado-dot-net-object-model-and-attributes) we have to pass the URL of the audio file.
- **autoplay:This** attribute specifies audio file is ready to play.
- **loop**: This attribute specifies audio file should replay or not.
- **[control](https://yourviews.mindstick.com/view/83439/bipartisan-gun-control-bill-passed-in-us-after-decades)**: This attribute specifies to show control on page (play/pause/stop button).
- **preload**: This attribute specifies audio file should be preloaded or not.

##### Following example demonstrate use of audio element in html5

```
<!DOCTYPE html  PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><!DOCTYPE HTML>      <html><body>     <audio src="Video/Sleep Away.mp3" controls="controls"></audio></body></html>
```

##### Output of following code snippet is as follows

![Audio element in HTML5](https://www.mindstick.com/mindstickarticle/e9bcce6a-1bb3-42e4-a256-49d02829c597/images/e860804f-9007-48ac-b070-37512446bde9.png)

---

Original Source: https://www.mindstick.com/articles/576/audio-element-in-html5

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
