Adding a picture or video is the easy part. Making it load efficiently and understandable to every visitor is the real goal.
What You Need to Know
Animated pictures can be distracting or uncomfortable for some visitors. If motion is essential, provide a way to stop it and consider a video format with controls or a still image alternative.
Try the Example
Take a look at the example. We’ll explain the important lines right below it.
<video controls loop muted playsinline width="480" poster="images/experiment-still.jpg">
<source src="media/experiment.webm" type="video/webm">
<source src="media/experiment.mp4" type="video/mp4">
Your browser cannot play this animation.
</video>
Let’s Read the Code
- <video>: The video element creates a video player and can include alternative formats.
- <source>: A source points to a media file or image choice with a type or other condition.
- controls: Controls asks the browser to provide its native audio or video player controls.
- width: Width gives a preferred or intrinsic media width, depending on the element.
Read the named elements and attributes together. They explain how the browser connects this feature to the rest of the page.
What Happens in the Browser?
The paths shown here refer to files in your own example project. Put real images and recordings in those locations before expecting them to load.
What if the resource is missing? Test the page with the media path temporarily broken. The surrounding text should still explain the important idea, and controls should remain understandable. This is especially important for slow connections and accessibility.
Your Turn
Try changing one file path or attribute. Notice whether the browser falls back to another source or shows missing content.
Common Beginner Mistakes
- Leaving out real media files or understandable text alternatives.
- Always check keyboard access, readable alternatives, and any missing files; a perfect player layout does not guarantee accessible content.
Key Takeaways
- Animated pictures can be distracting or uncomfortable for some visitors.
- <video>: The video element creates a video player and can include alternative formats.
- A meaningful HTML element is usually a stronger starting point than adding an ARIA role to a generic div. Also check what happens using only the keyboard.