Ajey
Ajey

Reputation: 8202

Difference between embed, object, and video tags?

As per my knowledge I know that the embed tag is used to embed videos from sites like youtube, object tag is for flash videos and video tags come under HTML5. But I am curious for in depth details of these tags and as a developer which one should be used where?

Upvotes: 4

Views: 5906

Answers (1)

user2752467
user2752467

Reputation: 844

embed is older and was for a long time nonstandard, but tends to have more universal support. It became part of the HTML standard with HTML5. It doesn't require a plugin to be specified for the embedded content; that's up to the browser to figure out.

object was added by the standard (HTML 4, if I remember correctly) as an alternative to embed. It requires you to specify a plugin. Internet Explorer had really terrible support for it. It was at one point (think 5+ years ago) common to serve object for most browsers and then provide embed as a fallback for Explorer. (There was also a really hacky way to do it with object only, but that was difficult and really rare to see actually used.)

video was added in the HTML5 spec and is fairly well supported now. Generally, browsers have codec support built in rather than relying on a plugin, but since it's up to the browser to determine that side of it, the web developer doesn't have to worry. Different browsers support different codecs so be sure to do your research; more than likely you'll have to serve at least two different formats if you want all browsers to support it.

These days, the general rule is to use video for video content, audio (another element that works similarly to video) for audio-only content, and embed for anything else (like Flash animations, for example).

To more directly answer your question, embed would probably be the best choice for Flash videos. YouTube has some form of HTML5 video support, but I'm no expert on YouTube stuff so definitely read their documentation.

Upvotes: 7

Related Questions