ARTLUNG LAB Share

1999

HTML Tags for Java Applets

In 1999, I took a class in Java at Santa Monica College. I was interested at the time in the small variations among how The W3C, Sun, Netscape, and Microsoft specified the <APPLET> tag.

So here are how each specified the tag in 1999, minus the formatting of the original pages:

All Tags W3C - HTML 3.2 W3C - HTML 4.0 Microsoft Netscape Sun

All Tags

W3C - HTML 3.2


 * @license  GPL 2.0+ - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @version  GIT: $Id$
 * @link     https://artlung.com/
 * @since    2024-12-03
 */
?>
https://www.w3.org/TR/REC-html32.html#applet

APPLET (Java Applets)

<!ELEMENT APPLET - - (PARAM | %text)*>
<!ATTLIST APPLET
codebase %URL     #IMPLIED   -- code base --
code     CDATA    #REQUIRED  -- class file --
alt      CDATA    #IMPLIED   -- for display in place of applet --
name     CDATA    #IMPLIED   -- applet name --
width    %Pixels  #REQUIRED  -- suggested width in pixels --
height   %Pixels  #REQUIRED  -- suggested height in pixels --
align    %IAlign  #IMPLIED   -- vertical or horizontal alignment --
hspace   %Pixels  #IMPLIED   -- suggested horizontal gutter --
vspace   %Pixels  #IMPLIED   -- suggested vertical gutter --
>

<!ELEMENT PARAM - O EMPTY>
<!ATTLIST PARAM
name    NMTOKEN   #REQUIRED  -- The name of the parameter --
value   CDATA     #IMPLIED   -- The value of the parameter --
>

Requires start and end tags. This element is supported by
all Java enabled browsers. It allows you to embed a Java
applet into HTML documents. APPLET uses associated PARAM
elements to pass parameters to the applet. Following the
PARAM elements, the content of APPLET elements should be
used to provide an alternative to the applet for user agents
that don't support Java. It is restricted to text-level
markup as defined by the %text entity in the DTD.
Java-compatible browsers ignore this extra HTML code. You
can use it to show a snapshot of the applet running, with
text explaining what the applet does. Other possibilities
for this area are a link to a page that is more useful for
the Java-ignorant browser, or text that taunts the user for
not having a Java-compatible browser.

Here is a simple example of a Java applet:

<applet code="Bubbles.class" width=500 height=500>
Java applet that draws animated bubbles.
</applet>

Here is another one using a PARAM element:

<applet code="AudioItem" width=15 height=15>
<param name=snd value="Hello.au|Welcome.au">
Java applet that plays a welcoming sound.
</applet>

codebase = codebaseURL
This optional attribute specifies the base URL of the
applet -- the directory or folder that contains the
applet's code. If this attribute is not specified, then
the document's URL is used.

code = appletFile
This required attribute gives the name of the file that
contains the applet's compiled Applet subclass. This
file is relative to the base URL of the applet. It
cannot be absolute.

alt = alternateText
This optional attribute specifies any text that should
be displayed if the browser understands the APPLET tag
but can't run Java applets.

name = appletInstanceName
This optional attribute specifies a name for the applet
instance, which makes it possible for applets on the
same page to find (and communicate with) each other.

width = pixels
height = pixels
These required attributes give the initial width and
height (in pixels) of the applet display area, not
counting any windows or dialogs that the applet brings
up.

align = alignment
This attribute specifies the alignment of the applet.
This attribute is defined in exactly the same way as
the IMG element. The permitted values are: top, middle,
bottom, left and right. The default is bottom.

vspace = pixels
hspace = pixels
These optional attributes specify the number of pixels
above and below the applet (VSPACE) and on each side of
the applet (HSPACE). They're treated the same way as
the IMG element's VSPACE and HSPACE attributes.

The PARAM element is used to pass named parameters to applet:

<PARAM NAME = appletParameter VALUE = value>

PARAM elements are the only way to specify applet-specific
parameters. Applets read user-specified values for
parameters with the getParameter() method.

name = applet parameter name
value = parameter value

SGML character entities such as é and ¹ are
expanded before the parameter value is passed to the applet.
To include an & character use &.

Note: PARAM elements should be placed at the start of the
content for the APPLET element. This is not specified as
part of the DTD due to technicalities with SGML mixed
content models.

W3C - HTML 4.0


 * @license  GPL 2.0+ - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @version  GIT: $Id$
 * @link     https://artlung.com/
 * @since    2024-12-03
 */
?>https://www.w3.org/TR/REC-html40/struct/objects.html#h-13.4

13.4 Including an applet: the APPLET element

APPLET is deprecated (with all its attributes) in favor of OBJECT.

See the Transitional DTD for the formal definition.

Attribute definitions

codebase = uri [CT]
This attribute specifies the base URI for the applet.
If this attribute is not specified, then it defaults
the same base URI as for the current document. Values
for this attribute may only refer to subdirectories of
the directory containing the current document.
code = cdata [CS]
This attribute specifies either the name of the class
file that contains the applet's compiled applet
subclass or the path to get the class, including the
class file itself. It is interpreted with respect to
the applet's codebase. One of code or object must be
present.
name = cdata [CS]
This attribute specifies a name for the applet
instance, which makes it possible for applets on the
same page to find (and communicate with) each other.
archive = uri-list [CT]
This attribute specifies a comma-separated list of URIs
for archives containing classes and other resources
that will be "preloaded". The classes are loaded using
an instance of an AppletClassLoader with the given
codebase. Relative URIs for archives are interpreted
with respect to the applet's codebase. Preloading
resources can significantly improve the performance of
applets.
object = cdata [CS]
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. Authors should use
this feature with extreme caution. An applet should be
stopped before it is serialized.

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

width = length [CI]
This attribute specifies the initial width of the
applet's display area (excluding any windows or dialogs
that the applet creates).
height = length [CI]
This attribute specifies the initial height of the
applet's display area (excluding any windows or dialogs
that the applet creates).

Attributes defined elsewhere

id, class (document-wide identifiers)
title (element title)
style (inline style information)
alt (alternate text)
align, hspace, vspace (visual presentation of objects,
images, and applets)

This element, supported by all Java-enabled browsers, allows
designers to embed a Java applet in an HTML document. It has
been deprecated in favor of the OBJECT element.

The content of the APPLET acts as alternate information for
user agents that don't support this element or are currently
configured not to support applets. User agents must ignore
the content otherwise.
DEPRECATED EXAMPLE:
In the following example, the APPLET element includes a
Java applet in the document. Since no codebase is supplied,
the applet is assumed to be in the same directory as the
current document.

<APPLET code="Bubbles.class" width="500" height="500">
Java applet that draws animated bubbles.
</APPLET>


This example may be rewritten as follows with OBJECT as follows:

<P><OBJECT codetype="application/java"
classid="java:Bubbles.class"
width="500" height="500">
Java applet that draws animated bubbles.
</OBJECT>

Initial values may be supplied to the applet via the PARAM element.
DEPRECATED EXAMPLE:
The following sample Java applet:

<APPLET code="AudioItem" width="15" height="15">
<PARAM name="snd" value="Hello.au|Welcome.au">
Java applet that plays a welcoming sound.
</APPLET>

may be rewritten as follows with OBJECT:

<OBJECT codetype="application/java"
classid="AudioItem"
width="15" height="15">
<PARAM name="snd" value="Hello.au|Welcome.au">
Java applet that plays a welcoming sound.
</OBJECT>

Microsoft


 * @license  GPL 2.0+ - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @version  GIT: $Id$
 * @link     https://artlung.com/
 * @since    2024-12-03
 */
?>https://www.microsoft.com/workshop/author/dhtml/reference/objects/APPLET.htm#APPLET

APPLET Element | APPLET Object


Places executable content on the page.
HTML Syntax

<APPLET
ALIGN=ABSBOTTOM | ABSMIDDLE | BASELINE | BOTTOM
| LEFT | MIDDLE | RIGHT | TEXTTOP | TOP
ALT=text
CLASS=classname
CODE=filename
CODEBASE=url
DATAFLD=colname
DATASRC=#ID
HEIGHT=n
HSPACE=n
ID=value
NAME=name
SRC=url
STYLE=css1-properties
TITLE=text
VSPACE=n
WIDTH=n
event = script
>

Remarks

This element is a block element.

Members

APPLET Members

Styles

APPLET Styles

Netscape


 * @license  GPL 2.0+ - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @version  GIT: $Id$
 * @link     https://artlung.com/
 * @since    2024-12-03
 */
?>https://developer.netscape.com/docs/manuals/htmlguid/tags14.htm#1237108

APPLET

(Java applet)

The APPLET tag specifies a Java applet that will run in a
web page. Applets can only be displayed by Java-enabled
browsers. Navigator 2.0

You build an applet using the Java language and compile it
with a Java compiler. It is beyond the scope of this
document to discuss how to write Java applets. However, an
excellent place to start learning about writing Java is the
Java Tutorial at:

https://java.sun.com/docs/books/tutorial/

After writing and compiling a Java applet, you can display
it in a web page by using the APPLET tag. The CODE attribute
specifies the name of the Java applet to run. The CODEBASE
attribute specifies the subdirectory or folder containing
the Java applet. You can use PARAM tags between the
<APPLET> and </APPLET> tags to provide
information about parameters, or arguments, to be used by
the Java applet.

Syntax

<APPLET
CODE="classFileName"
CODEBASE="classFileDirectory"
ARCHIVE="archiveFile"
ALT="altText"
ALIGN="LEFT"|"RIGHT"|"TOP"|"ABSMIDDLE"|"ABSBOTTOM"|
"TEXTTOP"|"MIDDLE"|"BASELINE"|"BOTTOM"
HEIGHT="height"
WIDTH="width"
HSPACE="horizMargin"
VSPACE="vertMargin"
MAYSCRIPT
NAME="value"
>
<PARAM ...>
</APPLET>

The CODE attribute is required (otherwise there is no applet
to run). Netscape Navigator 3 and Navigator 4 can display
applets if the WIDTH and HEIGHT attributes are omitted, but
some other browsers cannot, so for best results you should
always include the WIDTH and HEIGHT attributes.

CODE ="classFileName"

specifies the filename of the applet to load. All Java
class files end with a .class extension (for example,
myApplet.class). Many browsers will display the applet
correctly even if you omit the .class extension in the
filename.

CODEBASE="classFileDirectory"

is the directory containing the applet class file and
any resources the applet needs. The value is a URL for
an absolute or a relative pathname. An absolute URL is
used as is without modification and is not affected by
the document's BASE tag. A relative CODEBASE attribute
is relative to the document's base URL defined by the
BASE tag. If the document does not define a BASE tag,
it is relative to the directory containing the HTML
file.

ARCHIVE="archiveFile"

is a URL for a file in the CODEBASE directory to be
downloaded to the user's disk. The suffix on the
archive file must be .zip, but the file must not be
compressed. The browser searches the archive file for
the class file named in the CODE attribute. If the
browser cannot find that class file in the archive
file, it searches for it using the standard
mechanism.Navigator 3.0

ALT="altText"

specifies text to be displayed by browsers that do not
support the APPLET tag. Navigator 3.0

ALIGN

specifies the alignment for the applet. If you do not
provide a value for ALIGN, Navigator uses BOTTOM as the
default.

LEFT aligns the applet with the left margin.
Content following the applet flows around the
applet on the right. You can use <BR CLEAR>
to make content appear below the applet.
RIGHT aligns the applet with the right margin.
Content following the applet flows around the
applet on the left. You can use <BR CLEAR>
to make content appear below the applet.
TOP: The top of the applet is vertically aligned
with the tallest item in the current line. Only
one line of content is aligned with the applet.
Subsequent lines of content in the same
block-level element appear below the applet. If
the applet is not surrounded by content in the
same block-level element as the applet, then it is
aligned on the left.
ABSMIDDLE: The middle of the applet is vertically
aligned with the vertical middle of other content
(such as text or images) in the current line. The
content is moved down from its natural position in
the page to accommodate the alignment. Only one
line of content is aligned with the applet.
Subsequent lines of content appear below the
applet. If the applet is not surrounded by content
in the same block-level element as the applet,
then it is aligned on the left. Navigator 3.0
ABSBOTTOM : The bottom of the applet is vertically
aligned with the bottom of other content (such as
text or images) in the current line. The content
is moved down from its natural position in the
page to accommodate the alignment. Only one line
of content is aligned with the applet. Subsequent
lines of content appear below the applet. If the
applet is not surrounded by content in the same
block-level element as the applet, then it is
aligned on the left. Navigator 3.0
TEXTTOP aligns the top of the applet with the top
of the tallest text in the current line. If the
current line contains no text, the top of the
applet is aligned with the vertical middle of
other content (such as images) in the line. If the
applet is not surrounded by content in the same
block-level element as the applet, then it is
aligned on the left. Navigator 3.0
MIDDLE: The middle of the applet is vertically
aligned with the bottom (or baseline) of other
content (such as text or images) in the current
line. The content is moved down from its natural
position in the page to accomodate the alignment.
Only one line of content is aligned with the
applet. Subsequent lines of content appear below
the applet. If the applet is not surrounded by
content in the same block-level element as the
applet then it is aligned on the left. Navigator
3.0.
BASELINE -- The bottom of the applet is vertically
aligned with the bottom (or baseline) of other
content (such as text or images) in the current
line. The content is moved down from its natural
position in the page to accomodate the alignment.
Only one line of content is aligned with the
applet. Subsequent lines of content appear below
the applet. If the applet is not surrounded by
content in the same block-level element as the
applet then it is aligned on the left. Navigator
3.0.
BOTTOM is the same as BASELINE.

HEIGHT="height"

specifies the height of the applet. An integer value
(for example, "100") indicates the height in pixels. A
percentage value (for example, "25%") indicates the
height as a percentage of the height of the parent
window, frame, or block of content. The applet is
scaled to fit the specified height and width.You should
provide a width and height to ensure that all
Java-enabled browsers can display the applet.

WIDTH="width"

specifies the width of the applet. An integer value
(for example, "100") indicates the width in pixels. A
percentage value, (for example, "25%") indicates the
width as a percentage of the width of the parent
window, frame, or block of content. The applet is
scaled to fit the specified height and width. You
should provide a width and height to ensure that all
Java-enabled browsers can display the applet.

HSPACE="horizMargin"

specifies the horizontal space, in pixels, between the
applet and surrounding text. Give the value as an
integer.

VSPACE="vertMargin"

specifies the vertical space, in pixels, between the
applet and surrounding text. Give the value as an
integer.

MAYSCRIPT

permits the applet to access JavaScript. Use this
attribute to determine whether or not an applet can
access JavaScript on a page. If an applet accesses
JavaScript when the MAYSCRIPT attribute is not
specified, an exception will be generated. Navigator
3.0

NAME ="value"

specifies the name of the applet, so that different
applets in the same window can refer to (and
communicate with) one another. The name can also be
used by JavaScript functions and scripts.

Applet Example

The following example runs the applet jumping.class. It has
two input parameters, message and speed, that affect the
results of the applet. When this applet runs, it displays
the words in the message, a few words at a time. The words
come and go, so they seem to jump around at the specified
speed.

<P>Here is an applet. It has two parameters -- speed and message.
<APPLET CODE="jumping.class" CODEBASE=jclasses
WIDTH=240 HEIGHT=400
ALIGN=ABSMIDDLE HSPACE=10 VSPACE=20>
<PARAM NAME=message
VALUE="Use Netscape Navigator to browse the world wide web.">
<PARAM NAME=speed VALUE="4">
</APPLET>

Its alignment is ABSMIDDLE.
</P>

The file jumping.htm shows this example in action in a separate window.

Sun


 * @license  GPL 2.0+ - http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * @version  GIT: $Id$
 * @link     https://artlung.com/
 * @since    2024-12-03
 */
?>https://java.sun.com/products/jdk/1.1/docs/guide/misc/applet.html

JDK Contents
--------------------------------------------------------------------------------

The APPLET Tag
Here is an example of a simple APPLET tag:


<applet code="MyApplet.class" width=100 height=140></applet>


This tells the viewer or browser to load the applet whose
compiled code is in MyApplet.class (in the same directory as
the current HTML document), and to set the initial size of
the applet to 100 pixels wide and 140 pixels high.

Here's a more complex example of an APPLET tag:


<applet codebase="https://java.sun.com/applets/NervousText/1.1"
code="NervousText.class" width=400 height=75>
<param name="text" value="Welcome to HotJava!">
<hr>
If you were using a Java-enabled browser such as HotJava,
you would see dancing text instead of this paragraph.
<hr>
</applet>


This tells the viewer or browser to load the applet whose
compiled code is at the URL
https://java.sun.com/applets/NervousText/1.1/NervousText.
class, to set the initial size of the applet to 400x75
pixels. The viewer/browser must also set the applet's "text"
attribute (which customizes the text this applet displays)
to be "Welcome to HotJava!" If the page is viewed by a
browser that can't execute Java applets, then the browser
will ignore the APPLET and PARAM tags, displaying only the
HTML between the <param> and </applet> tags (the
alternate HTML).

Here's the result of putting the above example in your HTML
file. (The first time you load this page, you may have to
wait for the applet to be loaded.)


Here is another example of an APPLET tag:


<applet code=A21 width=256 height=256 archive="toir.jar">
<param name=img value=test.gif>
<hr>
We need to convert some of the standard applets to use
archive.  Any volunteers?
<hr>
</applet>


In this example, the applet class is A21. Its bytecodes
(may) reside in the archive "toir.jar". This archive may
also contain the image resource (see resources
documentation) with name test.gif.

Here's the complete syntax for the APPLET tag. Required
elements are in bold. Optional elements are in regular
typeface. Elements your specify are in italics.

<APPLET
CODEBASE = codebaseURL
ARCHIVE = archiveList
CODE = appletFile ...or...  OBJECT = serializedApplet
ALT = alternateText
NAME = appletInstanceName
WIDTH = pixels  HEIGHT = pixels
ALIGN = alignment
VSPACE = pixels  HSPACE = pixels
>
<PARAM NAME = appletAttribute1 VALUE = value>
<PARAM NAME = appletAttribute2 VALUE = value>
. . .
alternateHTML
</APPLET>

CODE, CODEBASE, and so on are attributes of the applet tag;
they give the browser information about the applet. The only
mandatory attributes are CODE, WIDTH, and HEIGHT. Each
attribute is described below.

CODEBASE = codebaseURL
This OPTIONAL attribute specifies the base URL of the
applet--the directory that contains the applet's code. If
this attribute is not specified, then the document's URL is
used.

ARCHIVE = archiveList
This OPTIONAL attribute describes one or more archives
containing classes and other resources that will be
"preloaded". The classes are loaded using an instance of an
AppletClassLoader with the given CODEBASE. The archives in
archiveList are separated by ",". NB: in JDK1.1, multiple
APPLET tags with the same CODEBASE share the same instance
of a ClassLoader. This is used by some client code to
implement inter-applet communication. Future JDKs *may*
provide other mechanisms for inter-applet communication.

CODE = appletFile
This REQUIRED attribute gives the name of the file that
contains the applet's compiled Applet subclass. This file is
relative to the base URL of the applet. It cannot be
absolute. One of CODE or OBJECT must be present.

OBJECT = serializedApplet
This attribute gives the name of the file that contains a
serialized representation of an Applet. The Applet will be
deserialized. The init() method will *not* be invoked; but
its start() method will. Attributes valid when the original
object was serialized are *not* restored. Any attributes
passed to this APPLET instance will be available to the
Applet; we advocate very strong restraint in using this
feature. An applet should be stopped before it is
serialized. One of CODE or OBJECT must be present.

ALT = alternateText
This OPTIONAL attribute specifies any text that should be
displayed if the browser understands the APPLET tag but
can't run Java applets.

NAME = appletInstanceName
This OPTIONAL attribute specifies a name for the applet
instance, which makes it possible for applets on the same
page to find (and communicate with) each other.

WIDTH = pixels HEIGHT = pixels
These REQUIRED attributes give the initial width and height
(in pixels) of the applet display area, not counting any
windows or dialogs that the applet brings up.

ALIGN = alignment
This OPTIONAL attribute specifies the alignment of the
applet. The possible values of this attribute are the same
as those for the IMG tag: left, right, top, texttop, middle,
absmiddle, baseline, bottom, absbottom.

VSPACE = pixels HSPACE = pixels
These OPTIONAL attributes specify the number of pixels above
and below the applet (VSPACE) and on each side of the applet
(HSPACE). They're treated the same way as the IMG tag's
VSPACE and HSPACE attributes.
<PARAM NAME = appletAttribute1 VALUE = value>
<PARAM NAME = appletAttribute2 VALUE = value> . . .
This tag is the only way to specify an applet-specific
attribute. Applets access their attributes with the
getParameter() method.

--------------------------------------------------------------------------------
Copyright © 1996 Sun Microsystems, Inc., 2550 Garcia
Ave., Mtn. View, CA 94043-1100 USA. All rights reserved.