Can we use an alt attribute with the video tag?


#1

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 but 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 can not 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.


FAQ: Learn HTML Elements - Intro to HTML - Videos
#2

"As attributes can not contain markup "… what does this statement means?


#3

" backwards-compatibility troubles" can u elaborate it ? what kind of trouble is this exactly?


#4

Attributes may not contain HTML mark up (tags), only printable characters.

The number one trouble would be a browser that does not support HTML5, which is when the VIDEO element was introduced. For a less generalized point of view, study the documentation and other articles relating to this element.


#5

We do have an alternative to alt (alternate text) that works across all browsers, the title attribute is valid on the VIDEO element.

<video title="Bruce Lee meets Jackie Chan" ...>

#6

but we can still give the external link under alt (alternate text) even though if it can’t contain markup.


#7

10m
We do have an alternative to alt (alternate text) that works across all browsers, the title attribute is validr on the VIDEO element.

since i just checked screen readers are not able to read the content using title attribute unlike alt


#8

Screen readers can be set to verbose on title attributes, but usually default to alternate text only so the user isn’t inundated with chatter. title attributes are global, and apply to other elements such as links, language change, page fragments, etc. It’s for this reason they are not turned on by default.


#9

the alt attribute contains only text, so how is it not possible to include that? it shouldnt contain “tags” you say. what can happen if i write, say, < video src= “xyz” controls alt =“video on so-and-so” > and close the element properly, and include the fallback url between them? please explain.


#10

Go the the W3.org site and look up the VIDEO element. Find the part that describes permitted attributes. That is where you will find your explanation.

Part of the reasoning is that ALT text describes a static image, not a changing one. That is what closed captioning is for.