HTML <applet> Tag

The historical use of the applet tag is now by and large obsolete.

This tag was used to include the Java applet (small server-side application written in Java) into a web page. Java applets, which were client-side programs that ran within the web browser, furnished the most common interactive content such as games, calculators, or data visualization.

It was specified within the applet tag as a conjugated form, that is carriage offset or other conjoined properties to the Java applet.

But today, the <applet> tag is not supported anymore, and Java applets have fallen out of favor due to factors that could be summed up as insecurity and also the arrival of web technologies such as JavaScript, HTML5, and CSS, which purportedly provide better-placed, safe, and effective modes of interactive content creation.

Let’s rewind some years and see how the applet tag was applied and what has taken its place.

The Syntax for the <applet> Tag

Here’s an example of how the <applet> tag would have been used back in the day:

<applet code="MyApplet.class" width="300" height="200">
<param name="paramName" value="paramValue">
</applet>

Breaking It Down

<applet>: was a tag for embedding a Java applet into your web page. The code attribute would point to the Java file (usually with a .class extension) containing the applet code.

code="MyApplet.class": is the attribute for specifying the location of the Java applet file. This can either be a local file (like MyApplet.class) or in URL form.

width="300" height="200": These attributes defined the dimensions of the applet on the web page, just as an image or video would be so defined.

<param>: Within the <applet> you could have used <param> to pass parameters to the applet. For example, these could include config settings, options, or other dynamic values for customizing.

name="paramName": Name of the particular parameter.
value="paramValue": Value assigned to the parameter.

Example of an Applet with Parameters

Let’s say you wanted to embed a simple Java applet that required two parameters. Here’s how you might have done it:

<applet code="GreetingApplet.class" width="400" height="300">
<param name="message" value="Hello, world!">
<param name="color" value="blue">
</applet>

In this example:

  • The GreetingApplet.class file is the Java applet.
  • The applet takes two parameters: message and color.
  • The message parameter would display “Hello, world!” and the color parameter might change the color of the text to blue.

Why Was the Applet Tag Deprecated?

According to TechTarget, “Java applets enjoyed a brief period of popularity in the mid-1990s to the early-2000s. Nevertheless, they gradually became impractical for a handful of different reasons.”

Security Issues: Java applets were considered a security risk since they could run the code that could harm users’ machines. As the Internet matured, these issues came to the limelight with browsers beginning to block applets altogether.

Lack of Universal Compatibility: There was no definite support for Java applets by all the current browsers and many did not support it. In addition to that, the users must have the Java plugin installed on their browsers, which, at times, proved to be an additional hassle.

The Rise of Modern Web Technologies: With the advent of JavaScript, HTML5, and CSS3, web developers had powerful, flexible, and secure ways to create interactive web content without having to rely on Java applets.