An embedded multimedia object. Often used in conjunction with <param>.
<object> Optional Attributes
classid="" can be used to specify the location of the object in the form of a URL or Windows Registry location.
data="" can be used to specify the location of the data for the object in the form of a URL.
codebase="" can be used to specify the base location from which relative URLs specified in the classid="", data="" and archive="" attributes should be taken.
declare="" can be used to specify that the object is a declaration only. It must be used in the format declare="declare".
type="" can be used to specify the content type of the data specified by the data attribute.
codetype="" can be used to specify the content type of the object.
archive="" can be used to specify resources relevant to the object. The value should be a URL or a number of URLs separated by spaces.
standby="" can be used to specify text that will be displayed while the object is loading.
width="" can be used to specify the width of the object (in pixels). This can also be done with CSS.
height="" can be used to specify the height of the object (in pixels). This can also be done with CSS.
name="" can be used to specify a name by which the object can be referenced.
tabindex="" can be used to specify where the element appears in the tab order of the page.
<object archive="uri" border=" { number | percentage } " classid="class ID" codebase="uri" codetype="MIME type" data="uri" height=" { number | percentage } " type="MIME type" width=" { number | percentage } ">
</object>
The >object< element’s purpose is to embed into a document a variety of different kinds of media files. Historically, it was used primarily for placing ActiveX controls onto a page, but it can also be used to embed images (.gif, .jpg, and so on), movie files and applets, video files, PDF documents, Flash, and even HTML.
While this element is specified in the HTML 4 recommendation, and thus constitutes valid markup, it’s often shunned in favor of the better supported, but nonstandard >embed< element.
To embed Flash using >embed<, rather than going down the nonstandard >object<route, use the following markup:
<object data="movie.swf"
type="application/x-shockwave-flash" width="200" height="100">
<param name="movie" value="movie.swf">
<param name="wmode" value="opaque">
</object>
The >param< element with the name of name="movie" helps Internet Explorer to load the Flash file. The name="wmode" encourages IE to play nicely with the {z-index:} property, allowing other elements to be placed on top of the Flash movie.
Example
In this example, a super-simple object element is used to display an image:
<object data="giant-dog.jpg">
</object>
The >object< element is used for media files, applets, and ActiveX objects. For images, it’s currently better practice to use the completely supported >img< element, rather than take a risk using >object<; >img< is also far less clunky to use.
The >object< element is not completely supported, although it has to be said that the support that is available very much depends on the type of >object< that’s being embedded. Internet Explorer displays simple images poorly, with horizontal and vertical scrollbars, but is able to display an embedded Word document, albeit with a warning in the form of an ActiveX alert. Safari and Firefox, on the other hand, behaves impeccably with images, yet no amount of coaxing or installing of third-party plugins will allow the Word document to display—even with Microsoft Office installed on the host machine. For this reason, before you apply it, you should consider the purpose for which you need to use the >object< element. If it’s to display images, you’ll likely be better off to use the >img< element.