NOTICE: This website is no longer updated or supported - as such many of the techniques used to build it may seem antiquated in the modern day. It is preserved for historical reasons only.

HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<applet> (Java Applet)


This element identifies the inclusion of a Java applet. The strict HTML 4.01 definition does not include this element; it has been deprecated in favor of <object>.

Syntax (HTML 4.01 Transitional Only)


<applet
align="bottom | left | middle | right | top"
alt="alternative text"
archive="URL of archive file"
class="class name(s)"
code="URL of Java class file"
codebase="URL for base referencing"
height="pixels"
hspace="pixels"
id="unique alphanumeric identifier"
name="unique name for scripting reference"
object="filename"
style="style information"
title="advisory text"
vspace="pixels"
width="pixels">
</applet>

Attributes Defined by Internet Explorer


accesskey="key" (5.5)
datafld="name of column supplying bound data" (4)
datasrc="ID of data source object supplying data" (4)
hidefocus="true | false" (5.5)
src="URL" (4)
tabindex="number" (5.5)
unselectable="off | on" (5.5)

Attributes Defined by Netscape


mayscript

Events Defined by Internet Explorer


onactivate, onbeforeactivate, onbeforecut, onbeforedeactivate, onbeforeeditfocus, onbeforepaste, onblur, oncontextmenu, oncontrolselect, oncut, ondataavailable, ondatasetchanged, ondatasetcomplete, ondeactivate, onfocus, onfocusin, onfocusout, onhelp, onkeypress, onload, onlosecapture, onmouseenter, onmouseleave, onmousewheel, onmove, onmoveend, onmovestart, onpaste, onpropertychange, onreadystatechange, onresize, onresizeend, onresizestart, onrowenter, onrowexit, onrowsdelete, onrowsinserted, onscroll

Element Specific Attributes


align
This attribute is used to position the applet on the page relative to content that might flow around it. The HTML 4.01 specification defines values of bottom, left, middle, right, and top, whereas Microsoft and Netscape also might support absbottom, absmiddle, baseline, center, and texttop.

alt
This attribute causes a descriptive text alternate to be displayed on browsers that do not support Java. Page designers should also remember that content enclosed within the <applet> element may also be rendered as alternative text.

archive
This attribute refers to an archived or compressed version of the applet and its associated class files, which might help reduce download time.

code
This attribute specifies the URL of the applet's class file to be loaded and executed. Applet filenames are identified by a .class filename extension. The URL specified by code might be relative to the codebase attribute.

codebase
This attribute gives the absolute or relative URL of the directory where applets' .class files referenced by the code attribute are stored.

datafld
This attribute, supported by Internet Explorer 4 and higher, specifies the column name from the data source object that supplies the bound data. This attribute might be used to specify the various <param> elements passed to the Java applet.

datasrc
Like datafld, this attribute is used for data binding under Internet Explorer 4. It indicates the id of the data source object that supplies the data that is bound to the <param> elements associated with the applet.

height
This attribute specifies the height, in pixels, that the applet needs.

hspace
This attribute specifies additional horizontal space, in pixels, to be reserved on either side of the applet.

mayscript
In the Netscape implementation, this attribute allows access to an applet by programs in a scripting language embedded in the document.

name
This attribute assigns a name to the applet so that it can be identified by other resources; particularly scripts.

object
This attribute specifies the URL of a serialized representation of an applet.

src
As defined for Internet Explorer 4 and higher, this attribute specifies a URL for an associated file for the applet. The meaning and use is unclear and not part of the HTML standard.

vspace
This attribute specifies additional vertical space, in pixels, to be reserved above and below the applet.

width
This attribute specifies in pixels the width that the applet needs.

Example


<applet code="game.class" align="left" archive="game.zip" height="250" width="350">

<param name="difficulty" value="easy">

<b>Sorry, you need Java to play this game.</b>

</applet>

Compatibility


HTML 2, 3.2, 4, 4.01, and XHTML 1.0 (transitional)
Internet Explorer 2, 3, 4, 5, 5.5, 6
Netscape 2, 3, 4, 4.5-4.8, 6, 7

Notes


The W3C specification does not encourage the use of <applet> and prefers the use of the <object> tag. Under the strict definition of HTML 4.01, this element is deprecated.

(X)HTML Elements
CSS Properties
Previous: address Next: area
< Home | About | Chapters | Examples | Errata | Reference | Site Map >