HTML <applet> Element
The <applet> element was historically used to embed Java applets in an HTML document. Java applets were small programs downloaded from a website and executed by a Java browser plug-in, allowing webpages to provide interactive features that early HTML could not provide on its own.
<applet> element must not be used in new HTML. Modern browsers no longer support Java applets, and interactive webpage features should be created with current web technologies such as HTML, CSS, and JavaScript.
Historical Syntax
Older HTML documents may contain markup similar to the following:
<applet code="Example.class" width="400" height="300">
Your browser does not support Java applets.
</applet>
This code is shown for historical reference only. The <applet> element and browser-based Java applets should not be used when creating or updating modern websites.
Attributes
The <applet> element historically supported several element-specific attributes. These attributes are obsolete along with the element and are included here only to help identify and understand older HTML source code.
| Attribute | Description |
|---|---|
align |
Controlled the alignment of the applet relative to surrounding content. |
alt |
Provided alternative text for browsers that could not display the applet. |
archive |
Specified one or more archive files containing classes and other resources used by the applet. |
code |
Specified the Java class file containing the compiled applet code. |
codebase |
Specified the base URL used to locate files required by the applet. |
height |
Specified the height of the applet's display area. |
hspace |
Specified horizontal space around the applet. |
name |
Assigned a name to the embedded applet. |
object |
Specified a serialized representation of an applet. |
vspace |
Specified vertical space around the applet. |
width |
Specified the width of the applet's display area. |
Historical Use
Java applets were used during the early years of the web to add functionality that HTML and early browser scripting could not easily provide. Applets were used for interactive demonstrations, games, animations, calculators, educational software, charts, and other application-like features within webpages.
The browser downloaded the Java bytecode referenced by the code attribute and relied on an installed Java plug-in to execute it. Additional settings could be supplied to an applet using nested <param> elements.
Why It Became Obsolete
The <applet> element depended on external Java browser plug-ins rather than native browser capabilities. Plug-ins introduced compatibility, security, performance, installation, and maintenance problems, while web standards gradually gained native features capable of providing rich interactive content without them.
Browser vendors eventually removed support for the plug-in technology required to run Java applets. The <applet> element is now classified as an obsolete and non-conforming feature in modern HTML.
Modern Alternative
There is no single HTML element that directly replaces a Java applet because applets could perform many different tasks. The appropriate replacement depends on what the original applet was designed to do.
Modern interactive webpage features are generally created with HTML for structure, CSS for presentation and animation, and JavaScript for behavior. Native elements such as <video>, <audio>, <canvas>, and <svg> can also replace functionality that once required browser plug-ins.
For example, a simple interactive calculation that once might have been implemented as an applet can now be created directly with HTML and JavaScript without requiring a browser plug-in.
Legacy Browser Support
The <applet> element may still be recognized by HTML parsers for compatibility with historical documents, but modern browsers no longer provide the Java plug-in support required to execute traditional Java applets. Encountering an <applet> element in old source code therefore does not mean its original application will still function.
Older browsers and browser versions that supported Java plug-ins could execute applets when a compatible Java environment was installed. This historical support should not be relied upon when maintaining or developing a modern website.
For detailed legacy browser compatibility information, see Can I Use: HTML <applet> Element .
Related Elements
The obsolete <applet> element was historically associated with the <param> element for supplying parameters to embedded content. Modern webpages should use the HTML element and web technology appropriate for the type of content or functionality being provided.
Specifications
The <applet> element is listed as an entirely obsolete, non-conforming feature in the WHATWG HTML Living Standard .
