W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n

<APPLET>...</APPLET>

Description

Embed a Java applet into the document. A Java applet is a program, written in the Java language. The browser assigns a rectangle portion of the window to the applet in which it runs. The size of this region is set in the HTML page.

If the applet needs external parameters to run, you have to supply these with the PARAM element.

DTD

Note: This element is deprecated, and this DTD fragment is taken from the
      Transitional DTD.

<!ELEMENT APPLET - - (PARAM | %flow;)* -- Java applet -->
<!ATTLIST APPLET
  %coreattrs;                          -- id, class, style, title --
  codebase    %URI;          #IMPLIED  -- optional base URI for applet --
  archive     CDATA          #IMPLIED  -- comma separated archive list --
  code        CDATA          #IMPLIED  -- applet class file --
  object      CDATA          #IMPLIED  -- serialized applet file --
  alt         %Text;         #IMPLIED  -- short description --
  name        CDATA          #IMPLIED  -- allows applets to find each other --
  width       %Length;       #REQUIRED -- initial width --
  height      %Length;       #REQUIRED -- initial height --
  align       %IAlign;       #IMPLIED  -- vertical or horizontal alignment --
  hspace      %Pixels;       #IMPLIED  -- horizontal gutter --
  vspace      %Pixels;       #IMPLIED  -- vertical gutter --  >
from the HTML 4.0 DTD, "Copyright © W3C, (MIT, INRIA, Keio). All Rights Reserved."

Attributes

Core attributes: class id style title

W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n
ALIGN
This attribute defines how the applet window is positioned on the page. The values work the same way as the values of the IMG element.

Value Description
ABSBOTTOM Aligns the bottom of the applet window with the lowest item in the line.

This value is not present in the HTML 3.2 and 4.0 standards.

ABSMIDDLE Aligns the middle of the applet window with the middle of the line.

This value is not present in the HTML 3.2 and 4.0 standards.

BASELINE Aligns the bottom of the applet window with the baseline of the text in the line. This result is the same as align="bottom".

This value is not present in the HTML 3.2 and 4.0 standards.

BOTTOM Aligns the bottom of the applet window with the baseline of the text in the line. This result is the same as align="baseline".
CENTER Aligns the middle of the applet window with the baseline of the text. This result is the same as align="middle", but this value is not present in the HTML 3.2 and 4.0 standards. So better use align="middle".
LEFT Places the applet window at the left margin of the page.
MIDDLE Aligns the middle of the applet window with the baseline of the text. This result is the same as align="center".
RIGHT Places the applet window at the right margin of the page.
TEXTTOP Aligns the top of the applet window with the top of the text in the line.

This value is not present in the HTML 3.2 and 4.0 standards.

TOP Aligns the top of the applet window with the top of the largest item in the line.


W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0n
4.0n
TV 1.2n
2.1n
ALT
Supply alternate text for browsers that cannot display the Java applet, but know how to handle the element.
W3 3.2n
4.0d
NS 3.0y
4.0y
IE 3.0n
4.0n
TV 1.2n
2.1n
ARCHIVE
Specifies a file to be downloaded to the user's disk, and then searched for the value specified in the CODE attribute. The file is sought relative to the value of the CODEBASE attribute. The suffix on the file must be .zip, but the file must not be compressed. Classes not found in the file are searched for through the standard mechanism.
W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n
CODE
The name of the class that contains the applet. This name must be the same as use in the source of the class. This means that you cannot rename an applet. To get the same applet with another name change the source of the class and recompile it. The name must end with .class.
W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n
CODEBASE
The directory where the Java class is stored. You must use this attribute if the class is stored in an other directory then the HTML file in which it is contained. This directory can be a relative path or an absolute path. This means you can include classes from other servers.
When the CODEBASE attribute is relative, then it is relative to the document-URL defined by the BASE element. If no base element is specified, then it is relative to the directory where the HTML file is.
W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n
HEIGHT
The height of the reserved space the browser assigns to the applet. This value can be given as a number of pixels or a percentage of the height of the current block.
W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n
HSPACE
Set the amount of space, in pixels, that the browser should keep free on the left and right sides of the applet window.

! Netscape Navigator 3.0 does not support this attribute correctly, only on the right side of the applet there's free space, and its 2 times the supplied value for the attribute.


W3 3.2n
4.0n
NS 3.0y
4.0y
IE 3.0n
4.0n
TV 1.2n
2.1n
MAYSCRIPT
MAYSCRIPT permits the applet to access JavaScript. Use this attribute to determine whether or not an applet can access JavaScript on a page without your knowledge. Accessing JavaScript when the MAYSCRIPT attribute is not specified results in an exception.
W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0n
4.0y
TV 1.2n
2.1n
NAME
Specifies the name of the applet, so that different applets in the same window can refer to (and communicate with) each other.
W3 3.2n
4.0d
OBJECT
This attribute names a resource containing a serialized representation of an applet's state. It is interpreted relative to the applet's codebase. The serialized data contains the applet's class name but not the implementation. The class name is used to retrieve the implementation from a class file or archive.

When the applet is "deserialized" the start() method is invoked but not the init() method. Attributes valid when the original object was serialized are not restored. Any attributes passed to this APPLET instance will be available to the applet.

You should use this feature with extreme caution. An applet should be stopped before it is serialized.

Either the attribute code or object must be present. If both code and object are given, it is an error if they must provide the same class names.


W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n
VSPACE
Set the amount of space, in pixels, that the browser should keep free above and below the applet window.

! Netscape Navigator 3.0 does not support this attribute correctly, only below the applet there's free space, and its 2 times the supplied value for the attribute.


W3 3.2y
4.0d
NS 3.0y
4.0y
IE 3.0y
4.0y
TV 1.2n
2.1n
WIDTH
The width of the reserved space the browser assigns to the applet. This value can be given as a number of pixels or a percentage of the width of the current block.

If you want you can have a look at the source of the Java applet in the example.

Examples

Source
<APPLET code="APPLET1.class" width="200" height="50" alt="A Java example">
This text is displayed by browsers that cannot handle Java-applets or when the
execution of applets has been disabled.
</APPLET>
 
Result
This text is displayed by browsers that cannot handle Java-applets or when the execution of applets has been disabled.
 
Source
This applet uses an alignment in its definition,
<APPLET code="APPLET1.class" width="300" height="50" align="texttop" hspace="25">
With a Java-enabled browser you would see an applet.
<PARAM name="text" value="A second Java example">
</APPLET>
and a parameter to supply the text.
 
Result
This applet uses an alignment in its definition, With a Java-enabled browser you would see an applet. and a parameter to supply the text.
Statistics