HTML and CSS Reference
The loop attribute isn't specified as an attribute on the embed element in the
HTML5 specification, but the Flash Player will respond by looping the playback for this
Notice in this example that the type attribute is not specified. When not specified,
the browser will “content sniff” to determine which plug-in should handle the resource
(specified in src ). This may be as complex as looking for any metadata on the resource
that indicates its type or as simple as looking for a plug-in that can handle a particular
file extension. In this case, a resource with the .swf file extension will get handed off
to the Flash Player. Of course, the type of file being embedded can be explicitly set by
providing a suitable MIME type in the type attribute, like so:
<embed src="game.swf" type="application/x-shockwave-flash"
In addition to the ambiguity of attributes, there is another issue with embed . It is a
self-closing element, like img , but it does not have an alt attribute. That means if the
element was not supported, nothing would show up! To deal with this, browsers added
a noembed element to provide content for situations where embed was unsupported.
However, the noembed element has since been marked obsolete in HTML5 and must
not be used.
All and all, despite its inclusion in the specification, embed is best avoided because
of its limitations and quirks. A better alternative is the object element, which we'll
look at next.
The object element
Because the issues with embed and the limitations of img , the object element was
chosen by the W3C in 1996 as a replacement for both. Although it never superseded
img , object did largely replace embed because it was more flexible (although Fire-
fox lagged in support for awhile). F or example, it has an opening and closing tag,
so—unlike embed —fallback content can be provided in the content area of the element.
As with embed , object has been slimmed down in HTML5 and has had several
attributes marked obsolete, but a few have been added as well. The attributes data ,
type , name , width , height , and usemap are the attributes retained from the pre-
vious specification, while the attributes form and typemustmatch have been added.
As you can already see, object is a more sophisticated element compared to embed .
object is not solely for plug-in media because it can also support images and nested