10.2. The Old Way — The Embed Tag

Early versions of HTML used the embed tag (<embed>) to represent non-HTML data within HTML documents. The <embed> tag has the following syntax:

<embed src="file_to_embed" name="name_of_embedded_object" width="width_in_pixels"
  height="height_in_pixels" hidden="true|false">

For example, the following could be used to embed a MIDI file (jinglebells.mid) in a Web document:

<embed src="jinglebells.mid" name="jinglebells">

When the document is displayed in Windows Microsoft Internet Explorer, a small media player control appears, as shown in Figure 10-2, and the MIDI file begins to play. Note that the hidden attribute could be used to hide the player from the user and the space the player occupies can be modified with the width and height attributes (but using values that are too small will hide some of the control).

Note, however, that many other platforms will not handle the embedded file as shown in Figure 10-2—Windows handles it deftly because of the built-in media player control available to applications. Other user agents on other platforms will require a separate plugin to utilize the content. For example, Mozilla Firefox will display a prompt, as shown in Figure 10-3, and will attempt to install Apple's QuickTime player if the user chooses Install Missing Plugins.

Figure 10-2. Figure 10-2
Figure 10-3. Figure 10-3

Another seldom-used tag ...

Get Web Standards Programmer's Reference: HTML, CSS, JavaScript®, Perl, Python®, and PHP 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.