Adding Plug-in Media with <embed>

The <embed> tag places a media object, such as a Flash movie or the controls for a RealAudio track, on a web page. It displays the media object in a rectangular area that behaves much like an inline image in terms of positioning in the flow of the text. The <embed> tag was originally created by Netscape for use with plug-in technologies. It is currently supported by both browsers; however, the HTML 4.0 Specification prefers the use of the all-purpose <object> tag for the placement of multimedia elements.

When the browser encounters the <embed> tag, it matches the suffix of the file name (Netscape also looks for the value of the type attribute) with the appropriate plug-in.

The following is a very simple example of the <embed> tag:

<EMBED SRC="url" HEIGHT="165" WIDTH="250" ALIGN="right" HSPACE="6">
</EMBED>

The src attribute is required to tell the browser the location of the media file to be played. Many media types require that the width and height values (the dimensions of the plug-in element in pixels) be specified in order for the plug-in to function.

If you are triggering plug-in functions from a script, you will need to give the element a name using the name attribute.

Like images, media objects can be positioned using the align attribute and its related hspace and vspace settings. In Internet Explorer, you can also specify alternative text with the familiar alt attribute.

There are a few special attributes that are only supported by version 4.0 ...

Get Web Design in a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.