Embed - A Tag With No Purpose

The <embed> tag is a proprietary one that only some browsers support. It is also a tag which serves no purpose whatsoever and so there is no reason why it should ever be used. What we are going to do is to look at the reason why this tag is unnecessary.

The most common object to embed into a web page using an embed tag is a flash animation. Adobe, the current owners of Flash provide the following code as their recommended way of attaching a Flash object into your page. Note that it uses the embed tag but wraps it inside of an object tag.

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"
width="550" height="400" id="myMovieName">
<param name="movie" value="myFlashMovie.swf" />
<param name="quality" value=high />
<param name="bgcolor" value="#FFFFFF" />
<embed href="/support/flash/ts/documents/myFlashMovie.swf"
quality="high" bgcolor="#FFFFFF" width="550" height="400"
name="myMovieName" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>
</object>

There is no particular reason why the object tag has been added around the embed tag since all the common browsers support embed even though it is non-standard. The object tag is supposed to be the standard way of attaching elements into the web page though and so presumably the object tag has been added in an attempt to get browsers that do support the standard way of attaching the element to use that method and only use the proprietary way for those that don't.

Unfortunately that isn't the effect that adding that particular object tag has. The presence of the classid attribute makes the object tag itself non-standard (at least in so far as which browsers support it) and is in fact a variant of the object tag that only Internet Explorer understands. The classid attribute identifies the ActiveX plugin that IE should use to process the element. The type attribute on the embed element serves the same purpose for all browsers that process the embed tag. Thist means that we now have two proprietary tags with the outer one only working for Internet Explorer while the inner one works for all major browsers (except for any that process the object tag since they will ignore the embed tag completely).

The thing is that IE could process the embed tag itself just as easily as it could process the object tag. Since both tags in this instance are proprietary we would be better off with one proprietary tag rather than two and so we can reduce the code down to the following and still have it function.

<embed href="/support/flash/ts/documents/myFlashMovie.swf"
quality="high" bgcolor="#FFFFFF" width="550" height="400"
name="myMovieName" type="application/x-shockwave-flash"
pluginspage="http://www.macromedia.com/go/getflashplayer">
</embed>

At this point it looks like I am arguing for the use of the embed tag but that isn't the case. The thing is that with a minor change to the object tag we can get a version of that which is actually standards compliant. (Note that the standard I am referring to here is the current HTML 4 strict standard and not any future proposed standards since my argument is that adding the embed tag to the HTML 5 standard is unnecessary).

Here is the standard compliant version of the object tag that does exactly the same thing as the two above variants.

<pbject type="application/x-shockwave-flash"
width="550" height="400" id="myMovieName">
<param name="movie" value="myFlashMovie.swf">
<param name="quality" value="high">
<param name="=bgcolor: value="#FFFFFF">
</object>

This is no longer and is perhaps somewhat easier to read than the proprietary embed tag is plus it has the benefit of actually being a part of the current standards.

So why don't people actually code their page this way instead of using one of the variants that uses an embed tag? The answer to that is Internet Explorer 6. That particular version of Internet Explorer (along with earlier versions) doesn't understand the standard compliant version of the object tag. That means that if you use a standard object tag by itself the code will not work in IE6. A few years ago IE6 had over 95% of the market and so using a version of the code that worked in IE6 was a priority. Now with the market share of IE6 falling it is becoming less important to use code that supports that browser as well as all the modern ones.

There is actually a way of using the proprietary object tag for Internet Explorer and the standard one for all other browsers and I demonstrate that on my page Flash and the Object Tag. That code ends up somewhat longer than the combination of using a proprietary object tag with a proprietary embed tag and is much longer than the version that uses just the proprietary embed tag. It has the benefit of allowing browsers other than IE to use the standard object tag plus the side benefit that the standards validator doesn't actually flag the proprietary version of the object tag as invalid (it is only proprietary in that only IE bothered to implement that variant since only IE uses activeX and so that variant isn't applicable to other browsers - it isn't actually contrary to the standards).So with this small amount of extra effort we can code our page using the object tags that are recognised by the standard rather than using a proprietary embed tag.

Things are much more clearcut once you reach the point where you have few enough visitors to your site using IE6 to be able to ignore those visitors. Once that occurs then you can just use the standard object tag which is just as short and easier to read than a proprietary embed tag is. The poiint in having the embed tag exist at all then is only relevant while people continue using IE6 because we already have standard compliant code that will work for all more modern browsers that is even tidier than an embed tag would be.

The timeframe that we are looking at for IE6 to disappear is much shorter than the timeframe required to actually have the new HTML 5 standard reach the point of becoming a recommended standard. This means that long before HTML 5 becomes relevant there will no longer be any reason for anyone to use the embed tag (other than that they don't know how to write HTML properly). There is therefore no reason why the embed tag should be added to HTML 5 as it will be completely redundant long before that standard is completed - if it isn't already.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate