Audio, Video & Embeds
Modern websites use audio, video, YouTube videos, maps and other embedded content. In this chapter, you will learn how to add multimedia content using HTML.
audio
Add sound, podcast, voice note or learning audio.
video
Add video lessons, demo clips and course previews.
source
Provide multiple file formats for better browser support.
iframe
Embed YouTube videos, maps and external pages.
After This Chapter, You Will Understand
This chapter teaches how to add multimedia and embedded content in webpages.
Audio
Add audio files with controls, source and supported formats.
Video
Add video with controls, poster, autoplay, muted and loop.
Iframe
Embed external content like YouTube and Google Maps.
Responsive Media
Understand the need for mobile-friendly embeds.
Adding Audio with audio Tag
The audio tag is used to add sound files such as voice notes, lessons and music.
1 Basic Audio Syntax
The <audio> tag is used to embed audio files. The controls attribute shows play, pause and volume controls.
<source src="lesson.mp3" type="audio/mpeg">
Your browser does not support audio.
</audio>
Audio Player Preview
Adding Video with video Tag
The video tag is used for lessons, demos, testimonials, product previews and training content.
Video Player Preview
This visual represents a video player area. Real video files will show play controls when uploaded.
2 Basic Video Syntax
The <video> tag embeds video content. The poster attribute shows an image before the video starts.
<source src="training.mp4" type="video/mp4">
Your browser does not support video.
</video>
| Attribute | Use | Example |
|---|---|---|
| controls | Shows play, pause and volume controls | <video controls> |
| autoplay | Starts video automatically | <video autoplay> |
| muted | Mutes the video sound | <video muted> |
| loop | Plays video repeatedly | <video loop> |
| poster | Shows image before video starts | <video poster="cover.jpg"> |
Embedding External Content
The iframe tag is used to display another webpage or external content inside your webpage.
Making iframe Responsive
Videos and maps should adjust properly on mobile screens.
3 Responsive Wrapper
A responsive iframe wrapper keeps video and map embeds in proper ratio on different screen sizes. The common video ratio is 16:9.
<iframe src="embed-url" title="Video Lesson"></iframe>
</div>
Create a Media Learning Page
Edit the code and click Run Code to see the output.
Mistakes Students Should Avoid
Media files and embeds need correct paths, attributes and responsible usage.
Wrong Habits
- Forgetting controls attribute in audio/video
- Using wrong media file path
- Uploading very large video files without compression
- Using autoplay unnecessarily
- Adding iframe without title attribute
Correct Habits
- Use controls for user-friendly playback
- Use correct file format and path
- Use poster image for videos
- Use title attribute in iframe
- Make embeds responsive for mobile users
Test Your Understanding
Select the correct answers and check your score.
1. Which tag is used to add audio?
2. Which attribute shows play and pause buttons?
3. Which tag is used to add video?
4. Which tag is used to embed YouTube videos or Google Maps?
5. Which video attribute shows an image before video starts?
Remember These Points
Revise these before moving to Chapter 11.
audio
The audio tag is used to add sound files to webpages.
video
The video tag is used to add video files to webpages.
source
The source tag provides media file path and type.
controls
The controls attribute shows play, pause and volume controls.
poster
The poster attribute shows an image before video starts.
iframe
The iframe tag embeds external content like YouTube and maps.