The <applet> tag in HTML was used to embed Java applets into any HTML document. The <applet> tag was deprecated in HTML 4.01, and it’s support has been completely discontinued starting from HTML 5. Alternatives available in HTML 5 are the <embed> and the <object> tags.
<applet attribute1 attribute2....> <param parameter1> <param parameter2> .... </applet>
Attributes: The <applet> tag takes a number of attributes, with one of the most important being the code attribute. This code attribute is used to link a Java applet to the concerned HTML document. It specifies the file name of the Java applet.
Here, HelloWorld is the class file, which contains the applet. The width and height attributes determine the width and height of the applet in pixels when it is opened in the browser.
Attributes available to be used in conjunction with the <applet> tag are as follows:
|Specifies the alignment of an applet.|
|alt||text||Specifies an alternate text for an applet|
|archive||URL||Specifies the location of an archive file|
|border||pixels||Specifies the border around the applet panel|
|codebase||URL||Specifies a relative base URL for applets specified in the code attribute|
|height||pixels||Specifies the height of an applet|
|hspace||pixels||Defines the horizontal spacing around an applet|
|mayscript||Any arbitrary value (conventionally “mayscript”)||Indicates whether the Java applet is allowed to access the scripting objects of the web page|
|name||name||Defines the name for an applet (to use in scripts)|
|vspace||pixels||Defines the vertical spacing around an applet|
|width||pixels||Specifies the width of an applet|
Parameters: Parameters are quite similar to command-line arguments in the sense that they provide a way to pass information to the applet after it has started. All the information available to the applet before it starts is said to be hard-coded i.e. embedded within it. Parameters make it possible to generate and use data during run-time of the applet.
<param name=parameter_name value=parameter_value>
The name assigned to the name attribute of the param tag is used by the applet code as a variable to access the parameter value specified in the value attribute. In this way, the applet is able to interact with the HTML page where it is embedded, and can work on values provided to it by the page during run-time.
In this piece of code, the applet file HelloWorld can use the variable named message to access the value stored in it, which is “HelloWorld”.
Note: There is still some browsers that support the <applet> tag with the help of some additional plug-ins/installations to work. Internet Explorer 11 and earlier versions with the help of plug-ins.
Supported Browsers: The browser supported by <applet> tag are listed below :
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet