- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <applet> Tag
HTML Tags
HTML <applet> Tag
The applet tag embedded small Java programs, called applets, into web pages in the 1990s and 2000s. Browsers removed Java support years ago for security reasons, so applets no longer run anywhere. The tag is obsolete.
What it did
Syntax
html
<applet code="ClassFileName.class" width="300" height="200">
Your browser does not support Java applets.
</applet>Attributes
| Attribute | Description |
|---|---|
| code | Specifies the name of the Java class file to be loaded. |
| archive | Specifies the location of the applet’s .jar file. |
| codebase | Defines the base URL for the applet’s class files. |
| width | Specifies the display width of the applet. |
| height | Specifies the display height of the applet. |
| name | Assigns a name to the applet instance. |
| alt | Provides alternate text for browsers that do not support Java applets. |
| object | Specifies the serialized applet object. |
| align | Defines alignment relative to surrounding elements. |
| hspace | Sets horizontal space around the applet. |
| vspace | Sets vertical space around the applet. |
None of these attributes do anything in a current browser.
Example
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Applet Tag Example</title>
</head>
<body>
<h2>HTML <applet> Tag Example</h2>
<applet code="HelloWorld.class" width="300" height="200">
Your browser does not support Java applets.
</applet>
<p><strong>Note:</strong> Modern browsers no longer support Java applets. Use the <object> tag instead.</p>
</body>
</html>A current browser shows only the fallback text, or nothing at all. The applet itself never starts.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| No | No | No | No | No | Partially |
What replaced applets
Nothing replaces them one to one, because Java in the browser is gone. What applets were used for is done today with:
- JavaScript for interactive tools, games and calculators.
<canvas>and WebGL for drawing and animation. See the canvas tag.- WebAssembly for heavy computation, including code originally written in other languages.
If an old page still contains <applet>, the content has to be rebuilt with these, not wrapped in another tag.
HTML <applet> Tag exercises
Use a canvas instead
Applets are gone. Make a drawing surface for JavaScript with the id board, 300 wide and 150 high.
Result
Check your answer to see it here.
