Instruction: Explain how to embed a video file in HTML5.
Context: This question tests the candidate's skill in using HTML5 multimedia elements, specifically video embedding, and their knowledge of the necessary attributes for optimal functionality.
Official answer available
Preview the opening of the answer, then unlock the full walkthrough.
First, you start with the <video> tag to define the video's placement within your HTML document. This tag is the cornerstone of embedding videos in HTML5 and signifies to the browser that a video player should be displayed in the webpage.
Within the <video> tag, it’s paramount to use the src attribute to specify the path to the video file you wish to embed. However, considering the diversity of web browsers and the video formats they support, I always recommend using multiple <source> tags inside the <video> element, each specifying a different video format. This ensures maximum compatibility across various browsers. For example, you might include MP4, WebM, and Ogg video formats to cover a broad...