Question
The text content of <video>
tags seems to behave in the same way as the alternative text for the <img>
tag. For consistency, can we use an alt
attribute with the <video>
tag instead?
Answer
This is a great observation! We can not use the <alt>
attribute within the opening <video>
tag. While this may seem inconsistent, this is actually by design as we might want our video element to contain some fallback options. For example, if the video doesn’t load we might want to display a link to another video that does. As attributes cannot contain markup, this scenario would not be possible with alt
attributes alone.
If this fallback handling gives the developer more control, you might be wondering why the <img>
tag doesn’t follow suit. The answer to this involves backwards-compatibility troubles.