<applet>

The <applet> tag allowed the inclusion of Java applets in web documents, but it's no longer supported in HTML5 because of security concerns.

<applet> Element

The <applet> element was used to embed Java applets in web pages, enabling interactive functionality. It included attributes such as <code>, <width>, and <height> to define the applet's behavior and appearance. However, the <applet> tag is deprecated in HTML5, and modern alternatives like <object> are recommended instead.

Syntax

index.html
<applet code="URL" height="200" width="100">
  ...
</applet>

<applet> Demo

To embed a video in your webpage, use the <video> element:

index.html
<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
</video>

To embed audio in your webpage, use the <audio> element:

index.html
<audio controls>
  <source src="horse.ogg" type="audio/ogg">
</audio>
To embed multimedia or external content, you can use the <embed> tag or the <object> tag.

Example

  • Embed a document using the <embed> element:
index.html
<embed src="snippet.html">
  • Embed an image using the <embed> element:
index.html
<embed src="img.jpg">
  • Embed a document using the <object> element:
index.html
<object data="snippet.html"></object>
  • Embed an image using the <object> element:
index.html
<object data="img.jpg"></object>

Key Points

  • Purpose: Used to embed Java applets in web pages for interactivity.
  • Attributes:
    • width and height: Define the applet's dimensions.
    • name: Identifies the applet instance.
    • archive: Specifies JAR files to load with the applet.
  • Obsolescence: The <applet> element is deprecated in HTML5; use <object> or <embed> instead.

Conclusion

The <applet> element was used to embed Java applets for interactivity in web pages, with attributes like <code>, width, and height defining its behavior and appearance. However, it has been deprecated in HTML5 due to security concerns and is no longer recommended. Modern alternatives like <object> and <embed> should be used to embed multimedia or external content. These alternatives provide better compatibility and security for web development.