Embed and Object elements

History of Embedding Content

Many years ago the support for media like audio and video was lacking. Many plugins like Adobe Flash rose to the occassion. They became quite popular and were adopted by many websites. But these plugins were insecure and had potential security flaws. There were many plugins that provided additional features not possible with only the browsers. Then due to the wide adoption of JavaScript and HTML5 technology by most of the browsers, these became obsolete. While browsers do support plugins, they are not required for any major websites. Browsers have become more robust. Now modern plugin refine the browsing experience rather than provide new experiences. Including common types of multimedia like images, audio and video has never been better. But there are still occasions where we need to embed some content to our websites. The embed and object elements are useful for this purpose.

Object element

The object element is an older element used for embedding content like java applets, flash files and other files. The object element requires two attributes data and type. The data attribute is used for specifying the source file and the type attribute is used for specifying the type of the file.

<object data="example.swf" width="300" height="399" type="application/x-shockwave-flash">
Your browser does not support plugins.
</object>

Embed element

The embed element is a newer way for including embedded objects. Similar to the object element it requires src attribute to represent the file and type for the file.

<embed src="example.swf" width="300" height="399" type="application/x-shockwave-flash">

You can embed any type of file like images, audio and video. But this is not recommended. These have seperate elements for a reason. Embedding these files has no advantages compared to dedicated elements.