Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML HTML Video and Audio Media Basics The Audio Element

Why do we need to put the src attribute inside the audio tag, a different process than in the tutorial wherein we put.

I was marked wrong at Challenge Task 2 of 4. It says:

On the <audio>tag, use the src attribute to add this url as the audio file. http:********.mp3

My question is that, why is it different than what is on the tutorial? Why can I not put the src inside the <source> tag?

Thank you for the response.

1 Answer

Chayan Martinez
Chayan Martinez
3,810 Points

My guess is because <source> tag goes for multiple meaning from pictures, to videos and to audio. So by putting the src attribute in the audio element, it tells the computer specifically what it is referring to and in the challenge, it is specifically talking about the audio and not both the video and audio. Even the URL slightly changes and maybe the computer builds a connection between the two sources URLs from <audio> and <video> since in a sense it's like you're communicating with the computer haha. Like in a way saying if you're gonna do it one way you gotta be specific and not be general about it I guess. Or maybe that was how it use to operate back when they made the video first and not HTML5 got an update and now the code is slightly different. I tried :P

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/source