HTML and CSS

But Your Honor, I Object!

Okay, the entire last section was filled with lies. Not that I'm trying to steer you wrongI'm trying to do quite the opposite. All external media should be addressed using the object element if you want to be using markup that exists in the valid world of HTML and XHTML.

However, there's a big stumbling block with using the object element, and that is that support for it is inconsistent across browsers and platforms. This is very disturbing from a purist's point of view because there's no other alternative within the specifications.

QUANTUM LEAP: OBJECT HANDLING IN XHTML 2.0

In XHTML 2.0, the object element becomes ubiquitous. In other words, any other elements for external objects, including the img element, are made obsolete. Obviously, it's preliminary to use XHTML 2.0 because your results will be limited to those very few browsers that support object for img. But it gives you a good idea of the direction XHTML is taking.


Here's what it boils down to, in simple terms: If you want your multimedia to be as consistent as possible across browsers, you have to turn to a proprietary element, the embed element. This element has never existed in any of the formal specs, but most all browsers support it; although your pages with the embed element will cause validation errors, they're going to work.

Conventional wisdom mixes both object and embed. So if you were to use this approach with the same Flash file just described, you'd end up with the markup shown in Example 3-8.

Example 3-8. Embedding a Flash movie file (SWF) into a page using <object> and <embed>
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100"
height="100" codebase="http://active.macromedia.com/flash6/cabs/
swflash.cab#version=6,0,0,0">
<param name="movie" value="media/ava.swf" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="quality" value="high" />
<embed src="media/ava.swf" width="100" height="100" play="true"
loop="true" quality="high"></embed>
</object>

The Flash movie will now play inline in almost every browser.