views:

1046

answers:

5

I get the following warning in a ASP.NET project using the <embed> tag to put a .swf:

Warning: Validation (XHTML 1.0 Transitional): Element 'embed' is not supported.

What is the "supported" way to do it instead???

+2  A: 

Use an <object> element.

See: http://www.w3.org/TR/REC-html40/struct/objects.html#h-13.3

embed is not standard but is the most widely supported.

<object type="application/x-shockwave-flash" data="movie.swf">
     <param name="movie" value="movie.swf" /> 
</object>

You can of course use other param elements for things like window mode (wmode) and such. However note that in IE the movie will need to be clicked to be activated, which is why many people use JS to dynamically replace elements with embed for all browsers so no clicking needs to be done in IE.

meder
+2  A: 

This article describes in pretty deep detail how to embed flash files while maintaining standards:

A List Apart: Flash Satay: Embedding Flash While Supporting Standards

Dereleased
+3  A: 

The embed tag was depreciated in XHTML in favour of the object element. See http://www.bernzilla.com/item.php?id=681 for more information on this, but in a nutshell:

<object type="application/x-shockwave-flash data="c.swf?path=movie.swf" width="400" height="300">
    <param name="movie" value="c.swf?path=movie.swf" />
    <img src="noflash.gif" width="200" height="100" alt="" />
</object>

Keep in mind though that using object doesn't always work correctly in older browsers, so do a bit of testing using both formats first. A List Apart has a brilliant article on this called "Flash Satay: Embedding Flash While Supporting Standards" which shows you the cross browser way of implementing it as shown in the example above.

Nathan Kleyn
s/depreciated/deprecated
meder
@meder Good catch, my typing is atrocious today. =]
Nathan Kleyn
+2  A: 

It might be worth looking into SWFObject, a lot of projects use it so that they can validate and also easily embed videos dynamically in a cross-browser way. If you don't need dynamic embedding or version detection, the Flash satay method Dereleased points to is another good way.

Ben
+1  A: 

HTML5 (and thus XHTML5) now allows <embed> element. Switch to HTML5 (<!DOCTYPE html>) and it will validate.

porneL