Flash and XHTML

In the past I’ve used Macromedia Dreamweaver’s insert feature ( “Insert -> Media -> Flash”) to inject the necessary HTML tags in order to display short flash movies/commercials on client websites. Recently I discovered that this doesn’t work quite as intended as my sites don’t validate over at W3C any more.

All my recent projects are made using XHTML and since <embed> is not part of the XHTML specification it will prevent the pages from validating. Fortunately there’s a very simple workaround.

This is how it used to look when generated in Dreamweaver:

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="350" height="350" title="Example">
<param name="movie" value="curveball.swf" />
<param name="quality" value="high" />
<embed src="curveball.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="350" height="250"></embed>
</object>

This is how it should look when embedded in a XHTML document:

<object type="application/x-shockwave-flash" data="curveball.swf" width="350" height="250" title="Example">
<param name="movie" value="curveball.swf" />
<param name="quality" value="high" />
<span style="display:block;text-align:center;">Your browser doesn't support Flash movies, <a href="http://www.macromedia.com/go/getflashplayer" target="_blank">click here to install the browser plugin</a>.<br /><br />
Or skip the installation and <a href="example.php" title="Another pahe">click here to go to a page</a>.</span>
</object>

As you can see the <embed> tag is completely removed along with the classid and codebase from the <object> tag. You can also include some information that will be displayed to visitors not able to load your Flash movie in case their browser doesn’t support Flash or the plugin is out of date. Since the <object> tag allows sister elements it degrades beautifully and will not affect the functionality when the plugin is supported.

Below is a tiny Flash game embedded the “new way” which also brings back some good memories from when I was a little boy (waiting and playing in my fathers office on his brown/yellow Tandberg EDB machine to go home while he was in a meeting…):

Your browser doesn’t support Flash movies, click here to install the browser plugin.

Sweet… 🙂

About Author