Fane
Fane

Reputation: 2076

Use GIFs in <video> tag, or use videos in <img> tags

I've been trying to get a way of showing both gifs and videos (.mp4, .ogg, .webm) within the same tag.

So, if it is within a <video>tag I would only change the source or the <source> to a gif or video and show it accordingly.

Unfortunately I'm not finding anything consensual that would allow doing this.

Does anyone got a simple solution before I move on to the hardest ones?

Upvotes: 6

Views: 23421

Answers (2)

Saeed sdns
Saeed sdns

Reputation: 980

You can use poster attribute in <video> tag to show gif files. but it is not a complete solution, because you can not use them (video and gif) together.

Upvotes: 2

dippas
dippas

Reputation: 60593

According to MDN

The HTML <video> element is used to embed video content. It may contain several video sources, represented using the src attribute or the element; the browser will choose the most suitable one.

Therefore gif - not a video content - is NOT an option to be used in <video> tag

Here is the list of supported formats for <video> and <audio>

Upvotes: 6

Related Questions