This website uses cookies

We use cookies to personalize content and ads, to provide social media features and to analyse our traffic. We also share information about your use of our site with our social media, advertising and analytics partners who may combine it with other information that you've provided to them or that they've collected from your use of their services. Please read more at our privacy policy page.



HTML <applet> Tag

The <applet> tag was used to define an embedded Java applet. The use of Java applets is now deprecated, because most browsers no longer support the use of plug-ins, including the Java plug-in.

The <applet> element can contain other HTML tags and text between its opening and closing tags.

Some browsers still support the <applet> tag, but they require additional plug-in or installations to work.

This element is deprecated in HTML 4.01 and is entirely obsolete in HTML5. Use the <object> element instead.

Syntax

The <applet> tag comes in pairs, which means that the content must be written between the opening (<applet>) and the closing (</applet>) tags.

Example

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <applet code="game.class" align="left" archive="game.zip" height="250" width="350">
      <param name="difficulty" value="easy">
      <b>You need Java to play this game.</b>
    </applet>
  </body>
</html>

Result

Let's see another example using the <object> tag as a replacement for the <applet> tag:

Example

<!DOCTYPE html>
<html>
   <head>
      <title>Title of the document</title>
   </head>
   <body>
      <object codetype="application/java" classid="java:programmingtutorials.class"
         height="200" width="200">Programming Tutorials</object>
      </applet>
   </body>
</html>

Result

Attributes

Attribute Value Description
align left
right
top
bottom
middle
baseline
Is used to position the applet according to other elements.
alt text Is used to create an alternate text for the applet.
archive URL Is used to define the archive file's location.
code URL Is used to define the Java applet's name.
object name Is used to define a reference to a serialized representation of an applet.
codebase URL Gives a relative base URL for applets specified in the code attribute.
height pixels Defines the height of the applet.
hspace pixels Is used to define the horizontal space around the applet.
name name Is used to give a name for the applet.
vspace pixels Is used to define vertical space around an applet.
width pixel Is used to define the width of an applet.

Browser support