You are here: Reference > HTML > attributes > code (applet, object)

code attribute (applet, object)

Browser support:
Sets the name of the Java class file that contains the Java applet.
The applet tag is not a standard HTML element, use the object tag instead wherever you can.
You can define the location of the file with the codeBase attribute or with the codebase parameter for the applet and the object tags, too.
The location can be an absolute or relative path as well. Relative paths are relative to the base URL. The base URL is the location of the current document, but it can be overridden by the base tag. See Example 1 and 2 for details.
JavaScript page for this attribute: code. You can find other example(s) there.

Possible values:

String that sets the name of the class file.
Default: this attribute has no default value.

Example HTML code 1:

This example illustrates the use of the code and codeBase attributes for applet tags:
<applet code="HelloWorld.class" codebase="/external/examples/common/java/" style="width:200px; height:50px;">
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the code attribute and the codebase parameter for object tags:
<object type="application/x-java-applet" code="HelloWorld.class" style="width:200px; height:50px;">
    <param name="codebase" value="/external/examples/common/java/" />
Did you find this example helpful? yes no

Supported by tags:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content