Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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?

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

Thank you for the response.