Lesson 2: Embedding content CHAPTER 2 51
The <object> tag
The <object> tag embeds an object within an HTML document. You can embed multimedia
such as audio, video, Java applets, ActiveX, PDF, and Flash in your webpages. The <object>
tag contains the following attributes.
■■data Supplies the URL of the resource to be used by the object
■■form Indicates one or more form ids to which the object belongs
■■height pecifies the height in pixels of the objectS
■■name efines the name of the objectD
■■type efines the MIME type of data specified in the data attributeD
■■usemap Indicates the name of a client-side image map to be used with the object
■■width pecifies the width in pixels of the objectS
IMPORTANT AT A MINIMUM
At a minimum, you must define either the data or type attribute.
The <object> tag can be used within the <body> element only. You might find <object>
examples that implement many more attributes than are defined in this list because older
versions of HTML supported other attributes, but HTML5 supports only the attributes that are
listed plus the global attributes.
You can also use the <object> tag to embed another webpage in your HTML document.
The following is an example of using the <object> element to embed a webpage in your
HTML document.
<object id="headerContent" standby="loading header..."
title="loading header..." width="100%" height="15%"
type="text/html" data="Header.aspx"></object>
As a rule, consider using the <iframe> tag when embedding a webpage from another
domain into your HTML document by using sandboxing. It’s made for that purpose, whereas
the <object> tag is a more general-purpose tag. The <object> tag behaves differently with
different browsers, and you might find that features such as tooltips work only with the
<iframe> tag and not with the <object> tag.
It is possible to embed images and image maps in your HTML document by using the
<object> tag, but you should avoid doing so. It’s best to use the <img> tag to embed images.
The text within the <object> element is alternate text to be displayed for browsers that do
not support the <object> tag.