Using the object and param Elements

Description

The object element achieves the same result as the embed element.

It has local attributes:data, type, height, width, usemap, name, form.

object element can also have Zero or more param elements.

The form attribute is new in HTML5.

The archive, classid, code, codebase, codetype, declare, standby, align, hspace, vspace, and border attributes are obsolete.

Example

The following code shows how you can use the object element to embed the same YouTube video.


<!DOCTYPE HTML>
<html>
<body>
  <object width="560" height="349"
    data="http://www.youtube.com/v/qzA60hHca9s"
    type="application/x-shockwave-flash">
    <param name="allowFullScreen" value="true" />
  </object>
</body><!--from ww w.  j av  a  2 s . c om-->
</html>

Click to view the demo

Note

The data attribute provides the location for the content. The type, width, and height attributes have the same meaning as for the embed element.

You can define the parameters that will be passed to the plugin using the param element.

You use one param element for each parameter you need to define.

param element use attribute name and value to define parameters.

Fallback Content

With the object element you can include content that will be displayed if the content you specify is not available.


<!DOCTYPE HTML>
<html>
<body>
  <object width="560" height="349" data="http://java2s.com/myimaginaryfile">
    <param name="allowFullScreen" value="true" />
    <b>Sorry!</b> We can't display this content
  </object>
</body><!--   w  w  w .ja  va 2 s.  c  om-->
</html>

Click to view the demo

The code above used the data attribute to refer to a file that doesn't exist.

The browser will display the content inside the object element instead. The param elements are ignored.





















Home »
  HTML CSS »
    HTML »




HTML Introduction
HTML Document
HTML Section
HTML Group Content
HTML Text Marker
HTML Table
HTML Form
HTML Embed