Skip to main content

WDS22 - HTML Audio and Something Exciting

In the last article, we learned about embedding YouTube Videos in HTML pages which was pretty easy and straightforward. 
After video and images, let's focus on the last element in media types that is audio. Let's see how we can use audios on our web pages to enhance them...

HTML <audio> element

To play an audio file in the HTML, we use <audio> tag. Let's see by an example...

<audio controls>
    <source src="sample.mp3" type="audio/mpeg">
</audio> 

All the attributes and tags work just like <video> tag we seen in WDS20 article 2 days before. Following are the file formats and associated media types of music files:
  • MP3: audio/mpeg
  • Ogg: audio/ogg
  • Wav: audio/wav 
Most of the browsers support the MP3 format, so you should use it as your first preference. Just like video post, I can't show live code example in jsfiddle, so try it in your own web browser with any audio file you have with correct source and type to see the result.
That's all for audio in HTML,
That's all for Media,
That's all for HTML
Yes, we all have learned a lot of HTML in last 22 days. There are some parts of HTML which we can only use when we learn javascript such as using API, drag and drop images in HTML and much more, but what we learned covers more than 95% HTML you will ever need in your life.
From the next article, we are going to see something very interesting and that is no other than CSS. You will actually start loving your web pages. CSS is very simple to understand but very difficult to master, but don't worry we will complete it as simply as we completed our HTML.
That's all for today. Let's meet tomorrow with CSS. Till the #keepCoding.

 

Comments