HTML <applet> Tag

Beginner
5 min read
Updated: Oct 2026
3 examples
Obsolete

Definition and Usage

The <applet> element once embedded a Java applet — a compiled Java program (.class / JAR) that ran inside the page through the Java browser plugin.

You pointed at the class with code, sized the box with width / height, and passed settings with <param>. Today, study it for legacy pages only — never ship it in new HTML.

Obsolete.

Removed from HTML5 / the Living Standard for authors. Modern browsers do not run Java applets; they show nested fallback text at most.

Use instead.

Prefer <script> + DOM/CSS, <canvas> / WebGL for drawing, or WebAssembly for heavy compute. For generic embeds, see <object> and <embed> (still not for Java applets).

HTML Syntax

syntax.html
<applet code=" ClassName.class" width="300" height="200">fallback</applet>

Both start and end tags were required. Nested text (and <param> children) acted as fallback when the applet could not run — which is what every current browser effectively does.

Attributes

Historical attributes on <applet> (all obsolete with the element):

AttributeDescriptionTry it
codeURL of the applet’s main .class file (relative to codebase when set)Try it
width / heightDisplay size of the applet area in pixelsTry it
codebaseBase URL/directory for class files referenced by codeTry it
archiveComma-separated JAR (or similar) archives containing the applet and librariesLegacy only
altShort text for environments that could not show the appletTry it
nameName so scripts could find the applet instanceLegacy only
alignPresentational alignment (left, right, top, …) — use CSS todayDeprecated style
hspace / vspaceExtra horizontal / vertical space in pixels — use CSS margin insteadDeprecated style
<param> (child)Name/value pairs passed into the Java programTry it

Global Attributes

The <applet> tag also supports the Global Attributes in HTML.

Live Preview

Applets do not execute here. This preview shows the fallback box modern browsers effectively give you — adjust size and message.

Simulated <applet> area. The .class never loads — only nested fallback text appears.

Fallback (modern browsers)
Java applets are not supported in this browser.

code="Clock.class" width="300" height="200" — Java does not run.

HTML Examples

Short legacy snippets for study. Use Try It Yourself for a live editor — output is fallback only.

Example 1 — Basic Applet Markup

Historical minimum: class file, size, and fallback text for when Java cannot run.

HTML
<applet code="Clock.class" width="300" height="200">
  Your browser does not support Java applets.
</applet>
Try It Yourself

How It Works

  1. Open <applet>. Set code to the main .class file name.
  2. Size the area. width and height reserve space (pixels).
  3. Add fallback text between the tags for browsers without applet support.
  4. Today: every modern browser skips Java and shows that fallback (or nothing if empty).

Example 2 — codebase, alt, and param

Pass configuration into the applet and locate classes under a base path.

HTML
<applet
  code="Animation.class"
  codebase="/applets"
  width="400"
  height="300"
  alt="Java animation demo"
>
  <param name="speed" value="fast">
  <param name="color" value="blue">
  Java applets are no longer supported. Use a modern browser demo instead.
</applet>
Try It Yourself

How It Works

  1. codebase sets the folder (or URL) where code is resolved.
  2. <param> children pass name/value pairs into the Java program.
  3. alt was a short description when the applet could not display.
  4. Fallback still wins today — params never reach a JVM in current browsers.

Example 3 — Modern Replacement with Canvas

Same idea (a small interactive area) without plugins — use HTML + a little script.

HTML
<canvas id="demo" width="300" height="80" aria-label="Simple clock demo"></canvas>
<script>
  const c = document.getElementById("demo");
  const ctx = c.getContext("2d");
  function draw() {
    ctx.clearRect(0, 0, c.width, c.height);
    ctx.font = "20px sans-serif";
    ctx.fillText(new Date().toLocaleTimeString(), 16, 48);
  }
  draw();
  setInterval(draw, 1000);
</script>
Try It Yourself

How It Works

  1. Draw with <canvas>. No plugin — the browser paints pixels via JavaScript.
  2. Get a 2D context with getContext("2d").
  3. Update on a timer (here, once per second) instead of a Java applet loop.
  4. Prefer this pattern (or DOM/CSS) whenever you find old <applet> markup.

Edge Cases & Pitfalls

Most “bugs” with <applet> today are expectations that Java still runs.

obsolete

Never use in new pages

Validators and HTML checkers flag <applet>. Plan a rewrite when you find it in production.

security

Plugin risk is why it died

Java applets were a common attack surface. Browsers removed the plugin; do not try to re-enable it.

fallback

Empty body = empty UI

If there is no nested content, users may see nothing useful. Always leave clear fallback (or replace the tag).

API

document.applets is empty

Kept for compatibility; it always returns an empty collection. See document.applets.

migration

object is not a Java fix

HTML once preferred <object> over <applet>, but that still needed a plugin. Use web-native tech instead.

Browser Support

The <applet> element is obsolete. Java Plugin support was removed from all major browsers (e.g. Chrome ~47, Firefox ~56, Safari ~14.1). MDN removed the element docs as irrelevant.

✓ Obsolete · Not supported

<applet>

No functional Java applet support in modern Chrome, Firefox, Safari, Edge, or Opera. Nested fallback content may still appear as plain text.

0% Modern applet runtime
Google Chrome Plugin removed (~47+)
Not supported
Mozilla Firefox Plugin removed (~56+)
Not supported
Apple Safari Removed (~14.1+)
Not supported
Microsoft Edge No Java Plugin
Not supported
Opera Plugin removed
Not supported
Internet Explorer Legacy plugin only · EOL
Legacy only
<applet> Not supported

Bottom line: Learn <applet> for history and legacy audits only. Build interactive UI with JavaScript, Canvas, CSS, or WebAssembly.

Key Takeaways

  • Role: <applet> once embedded Java programs via a browser plugin.
  • Core attrs: code, width, height, plus codebase, archive, and <param>.
  • Status: obsolete in HTML5 — do not use in new documents.
  • Replace with: JavaScript, <canvas>, CSS, or WebAssembly — no plugins.

One line: <applet> is web history — learn it to migrate away, not to build new features.

Default CSS Settings

When browsers still treated applet as a replaced element, user-agent styling was minimal. A typical idea:

default.css
applet {
  display: inline-block;
}

Presentational attributes like align, hspace, and vspace are obsolete — use CSS if you ever restyle legacy markup during migration.

Frequently Asked Questions

The applet element embedded a Java applet — a compiled .class (or JAR) program that ran in the browser through the Java Plugin for games, charts, and demos.
No. applet is obsolete and removed from the HTML Living Standard for authors. Do not use it in new documents.
No. Chrome, Firefox, Safari, Edge, and Opera removed the Java Plugin. You only see fallback content inside the tag (if any).
Use JavaScript with HTML and CSS for UI, canvas or WebGL for graphics, and WebAssembly when you need near-native compute — no browser plugins.
code named the applet’s main .class file. It could be relative to codebase. archive listed JAR files that held classes and resources.
document.applets is kept for compatibility but always returns an empty HTMLCollection because applet support was removed from browsers.

Next: area

Define clickable regions on an image map with the area element.

area tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful