📖 Full detailed notes here: Open in Notion
HTML5 introduced dedicated media tags (<audio> and <video>) for embedding multimedia content directly into web pages without requiring external plugins. These tags provide native browser support for playing audio and video files.
The <audio> tag is used to embed sound content. The 'controls' attribute adds audio controls like play, pause, and volume. Multiple source files can be provided using <source> tags for browser compatibility.
The <video> tag embeds video content in web pages. Similar to audio, it supports the 'controls' attribute and multiple source files. Additional attributes like 'width', 'height', and 'poster' (for thumbnail image) can be used.
Common audio formats for web include MP3 (widely supported, good compression), WAV (uncompressed, high quality but large file size), and OGG (open format, good compression). Providing multiple formats ensures cross-browser compatibility.
Different browsers support different media formats. Using proper, widely-supported formats ensures your media content works across all major browsers. Providing fallback options is essential for accessibility and user experience.
Common video formats include MP4 (most widely supported), WebM (open format, good compression), and OGG (open format). MP4 with H.264 video codec and AAC audio codec is currently the most compatible format for web video.
YouTube videos can be embedded using the <iframe> tag with the video's embed URL. This method leverages YouTube's player infrastructure and provides consistent playback across devices without hosting the video files yourself.
The <embed> tag is used to embed external content such as plugins, though it's largely replaced by more specific tags like <audio>, <video>, and <iframe>. It was historically important for including multimedia before HTML5.
The 'allowfullscreen' attribute (used in <iframe> tags) or the 'allow' attribute with 'fullscreen' value enables the fullscreen button in embedded videos. This provides users with an immersive viewing experience.
Multi-page websites consist of multiple HTML documents linked together through navigation. Each page typically shares common elements (header, footer, navigation) while having unique content. Proper file organization and relative linking are essential.
💻 Sample Code and Practice Questions: View on GitHub
💻 Blog Article: View on GitHub