Semantic HTML: Why does the <audio> element require the src attribute to be in its own <source> tag

Hi there,
I was doing the Semantic HTML: Audio and attributes lesson and i was wondering why you have to use a tag to add the src attribute.
ie <audio controls> <source src="" type=""> </audio>

Why cant it just be this.

audio src=“” type=“” controls></audio
It wouldnt let me put the opening and closing tags in their for some reason.

Thanks for any help

Hi there,

So, <source> is used to add multiple source files to different kinds of media–as not all browsers offer the same support for different kinds of file types. When using one source for your image, video, or audio–I’d say it’s optional to whichever you prefer. But, if you want to offer the browser multiple files of the same media, then you’ll want to use <source>.


<video controls>
  <source src="media.webm" type="video/webm">
  <source src="media.ogg" type="video/ogg">
  <source src="" type="video/quicktime">
  Sorry! Your browser does not support videos.

I hope this helps!

1 Like

That is really useful, thanks a lot for your help.

1 Like