Versión en español

HTML object tag

Note: If you don't know what a tag is and/or how you must use it we recommend you to read our HTML tags and attributes tutorial that you can find in our HTML tutorials section.

 

Description

The HTML object tag provides a way to run external applications. Generally, it's used to run applets, flash animations or to render images.

Attributes

id (name)

The "id" attribute assigns an identifier to the associated element. This identifier must be unique in the document and can be used to refer to that element.

Example:

Code begin <p id="paragraph1">This is the first paragraph named as paragraph1. To dynamically change its properties use this identifier.</p>Code end
 
 

class (cdata)

The "class" attribute assigns a class name (or a list of class names separated by spaces) to the container element. It's used with style sheets and tells the browser the class to which the element is associated with. A class gives visual attributes to elements.

Example:

Code begin <p class="references">This article is based on the book "Wind in the trees" by Jhon L. Brooks</p>

<p class="references important">This article is based on the book "Wind in the trees" by Jhon L. Brooks... and is more important than the one before.</p>Code end
 
 

style (style)

Defines a visual style of this element. Is a better practice to define styles attributes in external style sheets grouping them in classes. Attributes in the "style" parameter must preserve this order "name : value" and be separated by a semi-colon.

If you're writing XHTML code it's recommended not to use this attribute and try style sheet classes (with the "class" attribute).

Example:

Code begin <p style="color: #0000FF; font-size: 12pt">This is a paragraph with a defined style</p>
<p>And this is another text without style.</p>Code end
 
 

title (text)

Indicates a title for the element. Used to give a short description about the element that is usually shown as a "tool tip" when the user put the mouse pointer over the element.

Example:

Code View
<a title="HTMLQuick.com" href="http://www.htmlquick.com">HTML code</a> HTML code
 

lang (langcode)

Specifies the language of an element's content. The default value in "unknown".

When writing XHTML code the syntax "xml:lang" represents a preferred alternative in XHTML 1.0 and a replacement in XHTML 1.1 (e.g., xml:lang="en").

Example:

Code begin <p lang="en">This is a paragraph in english.</p>
<p lang="es">Este es un p&aacute;rrafo en espa&ntilde;ol.</p>Code end
 
 

dir

Specifies the text direction of the element's contents and attribute values, as well as tables directionality. It has two possible values that are case insensitive:
  • RTL: Right to left.
  • LTR: Left to right.
Example:

Code begin <q lang="he" dir="rtl">...a Hebrew quotation...</q>Code end
 
 

tabindex (number)

Specifies the position of this element in the tabbing order. The tabbing order defines the sequence with all the elements than can receive the focus. Users can navigate this sequence via keyboard (usually with the "tab" key).
 

usemap (uri)

This attribute specifies the image map to which this element is related to. To work correctly the "usemap" attribute of this element must match the "name" attribute from the associated HTML map tag.

Example:

Code begin <img src="http://www.htmlquick.com/img/examples/nav1.jpg" usemap="#nav1" alt="Navigation menu" /> Code end
 
 

name (cdata)

Assigns a control name to the element.
 

align

This attribute have been deprecated

Specifies the alignment of the element. This three values sets the element's position with respect to the surrounding text.
  • bottom: Means that the bottom of the object should be vertically aligned with the current baseline. This is the default value.
  • middle: Means that the center of the object should be vertically aligned with the current baseline.
  • top: Means that the top of the object should be vertically aligned with the top of the current text line.
This two values sets the position of a floating element:
  • left: Cause the image to float to the current left margin.
  • right: Cause the image to float to the current right margin.
 

width (length)

Assigns a width to the element.
 

height (length)

Assigns a height to the element.
 

border (pixels)

This attribute have been deprecated

Specifies the element's border width.
 

hspace (pixels)

This attribute have been deprecated

This attribute works as a margin for the element, defining the amount of white space to be inserted at the left and right sides of the element.
 

vspace (pixels)

This attribute have been deprecated

This attribute works as a margin for the element, defining the amount of white space to be inserted at the top and bottom sides of the element.
 

classid (uri)

Specifies a class identifier for the object.
 

codebase (uri)

It's used as the base path to resolve relative URIs in the values of "classid", "data" and "archive" attributes.
 

codetype (content-type)

Specifies the content type of the data defined in the "classid" attribute. This attribute lets the browser know if it supports the object before download it.
 

data (uri)

Specifies the location of the object's data.
 

type (content-type)

Designates the content type of the resource defined in the "data" attribute.
 

archive (uri)

May be used to specify a space-separated list of URIs that provide relevant archives for the object. This may help improve the loading time by preloading the archives content.
 

declare

This boolean attribute decides if the object's definition is a declaration only. If so, other object definition may be set as an instance by referring to this declaration.

Remember that boolean attributes must be defined as attr_name="attr_name" to be XHTML code compliant.
 

standby (text)

Assigns a message that the browser may display while the object is loading.
 


Events

  • onclick
  • ondblclick
  • onmousedown
  • onmouseup
  • onmouseover
  • onmousemove
  • onmouseout
  • onkeypress
  • onkeydown
  • onkeyup
See complete list and information about events in HTML


Examples

In this example, the HTML object tag is used to render an image.

Code View
<object data="http://www.htmlquick.com/img/links/button.jpg" type="image/jpg">
</object>

HTML object tag inserting a Flash animation.

Code View
<object classid= "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,0,0" id="HTMLQuick" width="88" height="31">
<param name="movie" value= "http://www.htmlquick.com/img/examples/htmlquick.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#FFFFFF" />
<embed src="http://www.htmlquick.com/img/examples/htmlquick.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="88" height="31"></embed>
</object>

Bypass footer options Send to a friend Send to a friend