A small piece of HTML can change what a visitor sees or how the browser understands a page. In this lesson, you will explore video poster selection and loading performance using a short example that you can inspect and change.
The Idea in Plain English
A poster image can appear before a video starts or when a frame is unavailable. Choose an informative crop and give the video sensible dimensions to reduce layout shifts.
You can test this using a small local HTML file. Change one part at a time and check the result in the browser before adding more code.
A Working Example
Read the sample once before copying it. Notice the element names and attribute values, then compare them with the explanation below.
<video controls preload="metadata" poster="/images/video-poster.jpg" width="960" height="540">
<source src="/video/lesson.mp4" type="video/mp4">
This browser cannot play the video.
</video>
What Each Part Does
- The video element provides a video player when a compatible source exists.
- A source offers an alternative file for a media element or picture.
- width reserves the image or embedded resource’s intended horizontal dimension.
- height reserves the image or embedded resource’s intended vertical dimension.
- src points to the asset the browser should load.
The visitor sees a preview frame and can use the controls to start the actual video.
Keep the example small while learning. Once it behaves as expected, try it inside a larger page and make sure the URLs, files and surrounding HTML are correct.
Try It Yourself
Try this next: demonstrate a safe and an unsafe snippet and validate behavior focused on Video Poster Selection and Loading Performance, including a working example and an incorrect example to correct. Then inspect the page and explain what changed.
Common Beginner Mistakes
- Using a huge uncompressed poster or treating it as a replacement for captions.
- Copying the code without checking whether its linked files or endpoints exist; sample addresses and file paths need real resources.
- Choosing a tag only because its default appearance looks right, without checking whether it describes the content correctly.
Key Takeaways
- A poster image can appear before a video starts or when a frame is unavailable. Choose an informative crop and give the video sensible dimensions to reduce layout shifts.
- The visitor sees a preview frame and can use the controls to start the actual video.
- Test the markup in a browser, and check accessibility and real-world behavior where relevant.