FAQ: Semantic HTML - Audio and Attributes

This community-built FAQ covers the “Audio and Attributes” exercise from the lesson “Semantic HTML”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Web Development

Introduction to HTML

FAQs on the exercise Audio and Attributes

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!
You can also find further discussion and get answers to your questions over in #get-help.

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head to #get-help and #community:tips-and-resources. If you are wanting feedback or inspiration for a project, check out #project.

Looking for motivation to keep learning? Join our wider discussions in #community

Learn more about how to use this guide.

Found a bug? Report it online, or post in #community:Codecademy-Bug-Reporting

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Why do you have to use a separate tag for audio? Is there a reason, why you can’t just add the src attribute directly to the audio tag, like you do with img: .

3 Likes

You don’t have to do it the way they showed it in the lesson, can can use the <audio> tag in the same way as the <video> tag.

Like:

<audio 
    controls 
    src="/media/examples/t-rex-roar.mp3">Your browser does not support the 
    <code>audio</code> element.
</audio>

One thing to take into account is that not all browsers support the same file types, so you might want to use multiple sources of different types of audio file, in that case, you will want to do it like they did it in the lesson:

<audio controls>
  <source src="myAudio.mp3" type="audio/mpeg">
  <source src="myAudio.ogg" type="audio/ogg">
  <p>Your browser doesn't support HTML5 audio. Here is
     a <a href="myAudio.mp4">link to the audio</a> instead.</p>
</audio>

Take a look at the example shown here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/audio#Attributes

2 Likes

If audio tag and video tag works well with a nested source tag, so it could work well in all media tags like img tag and so on?

Lesson: https://www.codecademy.com/courses/learn-html/lessons/semantic-html/exercises/audio-and-attributes

Great day.

Embedding Video Links in a list

I have a bit of a design question to do with embedded video.
To create a menu or a list with a number of embed videos in the menu or list, can I make the ,“video” element a child of the “li” element and how would this code look?

Also, can I embed a video that is linked to another site?

I did try this but because I could not define the video format as it was a link, I got an error message basically telling me that the file type wasn’t supported and that the browser couldn’t find or identify a file type. I am also pretty sure I can’t set a size for the video and then have the video open on a full screen when you press play using the code I have tried, but that is the result I am hoping to achieve. Suggestions and guidance here will be greatly appreciated.

(I have tried to include my code but for some reason I can not create a code block as described How do I format code in my posts?)

Cheers

Josh