Lesson 2.7: Multimedia – Audio, Video, Iframe
Multimedia content (like audio, video, and embedded external content) makes websites more engaging and interactive. HTML provides built-in tags to include multimedia directly without third-party plugins.
1. Audio in HTML
The <audio> tag is used to embed audio files.
Basic Syntax:
-
controls→ Adds play, pause, volume buttons. -
autoplay→ Starts playing automatically. -
loop→ Plays audio repeatedly. -
muted→ Starts muted by default.
Example with Attributes:
2. Video in HTML
The <video> tag is used to embed video files.
Basic Syntax:
-
controls→ Displays play/pause, volume, fullscreen. -
autoplay→ Plays video automatically. -
loop→ Repeats video. -
poster="image.jpg"→ Shows an image before the video starts.
Example with Poster:
3. Iframe in HTML
The <iframe> (Inline Frame) allows embedding external web pages, videos (like YouTube), maps, or other content inside a webpage.
Basic Syntax:
Common Uses:
-
Embed YouTube Video
-
Embed Google Map
4. Best Practices for Multimedia
-
Use multiple formats (
.mp4,.ogg,.webm) for compatibility. -
Keep file size small for faster loading.
-
Always include fallback text for unsupported browsers.
-
Do not autoplay with sound – it reduces user experience.
-
Use
iframeresponsibly (avoid untrusted sources for security).
✅ With multimedia elements, you can add sound, video tutorials, background music, and even external content like YouTube or Google Maps into your website.
