Can we use an alt attribute with the video tag?


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?


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.


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


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


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.


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" ...>

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

1 Like

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


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.


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.

1 Like

Go the the 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.


But consider a situation where a blind person has used a device that can’t play the video. How will he know there was a video and it isn’t supported?

Welcome to the forums, @beta6078252934,

The video element has a text node where we write the message,

Your device does not support video

still the concept is not clear. what does the alt tag represents that it can’t be used in a video tag? what if i write <video src =“xyz.mp4” controls alt=“The video is about a grizzly bear”.> why is that wrong?

1 Like

Thanks for the suggetion.


I hate to bring this back up again, but could you give an example?

You can’t give an external link under alt here at codecademy and have it display automatically. I tried.

    <img src="" alt=""/>

I misspelled bear(beat) so it would use the alt. If this is giving the link then sure you gave it and it displayed in the browser. The person using this web-page would then need to copy/paste the link to another browser tab to see the image.

1 Like

Makes sense! Thank you!