HTML Video
The Media overview pointed you at several families. This session focuses on one: the video element for clips and demos you host yourself. Give visitors play and pause UI with controls instead of surprising them with auto-started sound.
What video does
video tells the browser to fetch a movie file and paint it in the page. You can point to one file with src, or list several <source> children so the browser can pick a supported format. Optional attributes reserve size (width / height), show a still frame before play (poster), and expose native controls.
Direct answer
Use <video controls src="movie.mp4"> or nest <source> children for several formats. Add a poster image for a preview frame before play. Include short fallback text (and optionally a download link) inside video for agents that cannot play the media. Prefer compressed, reasonably sized files.
Simple video with controls
A single MP4 plus controls and a width is enough for many teaching pages.
Simple video with controls
html<video controls width="480" src="media/demo.mp4">
Sorry, your browser does not support this video.
</video>
Reading the simple sample
controlsasks the browser for play/pause UIwidth="480"helps reserve layout space while the file loadssrcpoints to the movie file in yourmediafolder- Text inside
videois fallback content when the element is not supported
Multiple sources and a poster
Browsers differ in format comfort. Listing WebM and MP4 with type hints, plus a poster still, is a common practical pattern.
Multiple sources and poster
html<video controls width="480" poster="media/demo-poster.jpg">
<source src="media/demo.webm" type="video/webm">
<source src="media/demo.mp4" type="video/mp4">
Download the <a href="media/demo.mp4">MP4</a> instead.
</video>
Reading the multi-source sample
postershows a preview image until playback starts- Each
sourcenames a file and a MIMEtype - The browser chooses the first source it can play
- The download link inside helps when playback is unavailable
File size and formats
Huge camera exports stall on slow networks. Export a web-sized MP4 (and optionally WebM) that matches the teaching need — short demos beat multi-gigabyte masters on a lesson page. You do not need every container on day one; get one clear MP4 working, then add a second format if your audience requires it.
Autoplay: learn controls first
Autoplay with sound is often blocked and usually poor manners. Muted autoplay tricks exist for marketing heroes, but beginners should master controls and user-started playback first. When you need autoplay later, read browser policies carefully and keep an accessible pause path.
Captions and accessibility (habit)
If spoken content teaches something important, plan captions or a transcript — even if you wire full track elements in a later pass. Do not rely on the poster image alone as the only accessible summary of a talking-head lesson.
Width, height, and layout
Setting width (and matching height when you know the aspect ratio) reduces layout jump as the video metadata loads. Stretching with mismatched numbers looks wrong; keep the real aspect ratio in mind the same way you did for images.
Practice in your editor
- Place a short
.mp4in amediafolder. - Embed it with
video+controls+ a sensible width. - Add fallback text inside the element.
- Optionally add a
posterimage and a secondsourceformat. - Open the page, play and pause, then test with the network throttled if you can — notice why file size matters.
Easy mistakes
- Missing
controlsso users cannot play easily - Shipping huge uncompressed files that stall on slow networks
- Forgetting fallback text or a download link
- Reaching for autoplay with sound before you understand basics
- Putting
altonvideothe way you do onimg(use captions/transcripts and visible descriptions instead) - Confusing hosted YouTube embeds (
iframe) with self-hostedvideofiles
Summary
videoembeds movie files you host- Use
controlsfor play UI - Multiple
sourcetags improve format support postershows a preview frame before play- Prefer compressed files and avoid surprise autoplay sound
🧠 Test Your Knowledge
Test Your Knowledge
Challenge yourself with this interactive quiz and see how well you understand the topic
📝 Instructions
- Read each question carefully
- Select the best answer for each question
- You can retake the quiz as many times as you want
- Your progress will be shown at the top