DEV Community

Jonathan Cohen
Jonathan Cohen

Posted on

The Audio tag

This week I started working on a project to help me review what I've learned so far. I'm working on a static page about what I did before I became a developer. This page would require the ability to play audio in order for the user to be able to hear the provided music on the page. I didn't have to search far to find out about the audio HTML element.

While I'm not a pro yet, I can at least share some of what I learned while I've been working with it. First, this element has an opening and closing tag. Second, much like the element, an attribute of the audio element is 'src'. The src will be set equal to the particular file you want to use. Given that you provide the correct relative file path, you should be able to press play and take a listen. The audio element comes with a few other convenient attributes as well. The 'controls' element gives the audio player the default controls(play, pause, etc.) Autoplay begins to play automatically when the page loads. I didn't need much for my project but there are so many more attributes that can be used.

I didn't go too far down the road of possibilities with this element yet, but it's great to know that this exists. As I said earlier, I'm not a pro yet just wanted to share what I've learned so far using it. I can't wait to experiment further.

Top comments (0)