YouTude Embeds

When HTML 4 was introduced in 1997 the <object> tag was introduced as a replacement for a number of proprietary tags. One of these proprietary tags was the <iframe> tag that is used for embedding one web page inside another web page. This new tag didn't work properly in early versions of Internet Explorer and so it wasn't until Internet Explorer finally died out that it became possible to replace the iframe tag with an object tag and know that it would work properly for embedding another web page.

Another use for the object tag was as a replacement for the proprietary <embed> tag. Again this didn't work properly in early versions of Internet Explorer and so it wasn't until IE6 died out that it became possible to use a single object tag for this purpose.

Just after it became possible to use the object tag properly for both these purposes HTML 5 replaced HTML 4 as the standard and it introduced the iframe tag as a standard tag for backwards compatibility for all of the web pages that were still catering for people using IE6 and IE7 browsers - even though the use of those two browsers had effectively died out by that point. HTML 5 also introduced a new <video> tag that allows video to be embedded into the web page and run directly by the browser instead of needing a plugin in order to play the video via the object or embed tag.

At this point you might be wondering what this has to do with YouTube. Well YouTude was a site that had been using the embed tag to allow people to embed YouTude videos into their own sites but which had updated their generated code to use the object tag instead once IE6 died out. For example:

<object width="475" height="381">
<param value="" name="movie"/>
<param value="window" name="wmode"/>
<param value="true" name="allowFullScreen"/>

This code worked fine in HTML 4 once you stopped caring about IE6 (which required a slightly different version of the object tag to work. What it doesn't do is to add the HTML 5 video tag as a wrapper around that object in order to make use of the new built in video playing ability of browsers that support HTML 5 video. Now YouTube could have added the extra video tag wrapper to their generated code but then they would have several places in the generated code to reference the particular video to be played and a greater possibility of the code being messed up.

Now YouTube staff realised that the object tag had replaced embed but apparently overlooked that object had also replaced iframe. What they did was to make a basic web page for each video with JavaScript that worked out which variant of the video or object tag was required to be able to properly play the video in the particular browser. Apparently they didn't realise that they could do it entirely with HTML by nesting an object tag inside of a video tag either as they have a huge amount of JavaScript performing the tests and generating the HTML.

The new code they generated for embedding videos no longer had an object tag as shown above, instead it has an iframe tag:

<iframe width="475" height="381" src="">

Now it is safest to not mess about with the actual web page on the YouTube site as they can change how that works at any time and so if you generate your own version you risk having it break if they change how their videos work. You can get rid of the unnecessary iframe tag though by converting it to the object tag equivalent:

<object width="475" height="381" type="text/html" data="">

You will see lots of places recommending that when embedding YouTube videos that you should use iframe rather than object so as to avoid the need for modern browsers to have a plugin installed. The object tag that is being referred to in this case is the one in the first example above. They are not talking about the second object tag above as they like YouTube have overlooked that the iframe tag became obsolete when IE7 dies and it became possible to use an object tag as an iframe replacement. This second object tag achieves the same end result as the iframe version and is also valid HTML 4 code and doesn't rely on tags introduced in HTML 5 that were already obsolete but where too many people are still using them to make it possible for browsers to drop the tag. The iframe and embed tags should have been completely dropped by browsers that support HTML 5 but because people writing HTML don't appear to understand that the word "deprecated" means that it is already obsolete and is going to be dropped in the next version, HTML 5 was unable to completely drop support for these long obsolete tags but had to add them into the standard to let the browser owners know that they need to continue to support these tags because most web pages are still written in HTML 3.2 regardless of what doctype is specified.

go to top

FaceBook Follow
Twitter Follow