Description
The HTML element <applet>
is used to embed a Java applet into an HTML document.
An applet is a mini Java application that can be included within an HTML page, similar to the way an image is included.
The below table summarizes its usage.
Usage Details | |
Placement | It is displayed as a Block element. |
Contents | It can contain Block elements, Inline elements, and text. In case the <param> element is included, it must come first. |
Tags | Both opening and closing tags are required. |
Versions | HTML 2, 3.2, 4, 4.01 This element is deprecated in HTML 4.01 and obsolete since HTML5, so avoid using this element in your markup. Instead, use the <object> element. |
Syntax
Here is the basic syntax of the <applet>
element.
<applet code="URL" width="number" height="number">...</applet>
Examples
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example - HTML Element applet</title>
</head>
<body>
<applet code="Sample.class" width="400" height="300">
<param name="delay" value="30">
<param name="time" value="120">
</applet>
</body>
</html>
Attributes
The following table shows the list of supported and unsupported attributes for the <applet>
element.
Attribute Type | Details |
Element-Specific Attributes | The tag <applet> has some element-specific attributes listed in the below table. |
Global Attributes | Like all other HTML tags, the tag <applet> supports the HTML Global Attributes. |
Event Attributes | The tag <applet> also supports the HTML Event Attributes. |
Here is a list of attributes that are specific to the <applet>
element.
Attribute | Value | Required | Description |
code |
left, right, center, justify, char | Yes | Specifies the URL of the Java applet's class file to be embedded. |
width |
number | Yes | Specifies the initial width of the applet display area. |
height |
number | Yes | Specifies the initial height of the applet display area. |
align |
character | No | Specifies the alignment of the applet element with respect to the surrounding content. |
alt |
number | No | Provides an alternate text to be displayed if the applet cannot be resolved or displayed. |
archive |
URL | No | Specifies a comma-separated list of URLs for archives containing classes and other resources that will be "preloaded". |
codebase |
URL | No | Specifies the URL of the directory where applets' .class files referenced by the code attribute are stored. |
hspace |
pixels | No | Specifies the amount of additional whitespace to be reserved on the left and right sides of the applet. |
name |
text | No | Specifies the name of the applet. |
vspace |
pixels | No | Specifies the amount of additional whitespace to be reserved on the top and bottom sides of the applet. |
Browser Compatibility
The tag <applet>
is supported in all modern browsers.
- Google Chrome 1+
- Internet Explorer or Edge 4+
- Firefox 1+
- Apple Safari 1+
- Opera 4+