SiteLint documentation and guidelines

Applet missing body

Description

The <applet> element in HTML is used to embed Java applets in a webpage. While this element is largely obsolete and replaced by <object> and <embed> elements, it can still be found in legacy web applications. The body of the <applet> element, which includes the fallback content or alternative text, is crucial for accessibility. If the body of the <applet> element is missing, users who cannot access the applet (e.g., due to browser restrictions, lack of plugin support, or disabilities) will not receive any information about the content or purpose of the applet.

Disabilities impacted

  • Visual impairments: users with visual impairments who rely on screen readers need alternative text or fallback content to understand the purpose of the applet.
  • Cognitive disabilities: users with cognitive disabilities benefit from descriptive fallback content that helps them understand the applet’s function.
  • Technical limitations: users on devices or browsers that do not support Java applets will not be able to access the content without proper fallback content.

Why it matters

Providing fallback content or alternative text in the body of the <applet> element ensures that all users, regardless of their ability to access the applet, can understand its purpose and function. This practice enhances accessibility and usability, ensuring a more inclusive web experience.

Coding problems and solutions

Common coding problems

  • Missing fallback content: the <applet> element lacks any content between its opening and closing tags.
  • Non-descriptive fallback content: the fallback content does not provide meaningful or relevant information about the applet.
  • Obsolete element usage: using the <applet> element instead of modern alternatives like <object> or <embed>.

How to fix it

Include descriptive fallback content

Ensure that the <applet> element includes meaningful fallback content that describes its purpose and function.

Correct example
<applet code="ExampleApplet.class" width="300" height="200">
    Your browser does not support Java applets. Please use a modern browser or enable Java support.
</applet>
Incorrect example
<applet code="ExampleApplet.class" width="300" height="200"></applet>

Use modern alternatives

Replace the <applet> element with <object> or <embed> elements, which are more widely supported and provide better accessibility options.

Correct example
<object type="application/x-java-applet" data="ExampleApplet.class" width="300" height="200">
    Your browser does not support Java applets. Please use a modern browser or enable Java support.
</object>
Incorrect example
<applet code="ExampleApplet.class" width="300" height="200"></applet>

Provide meaningful alternative text

Ensure that the fallback content is descriptive and provides context about the applet’s functionality.

Correct example
<applet code="WeatherApplet.class" width="300" height="200">
    This applet displays the current weather conditions. Please use a modern browser or enable Java support to view it.
</applet>
Incorrect example
<applet code="WeatherApplet.class" width="300" height="200">
    Weather applet.
</applet>

Known limitations

  • Legacy support: the <applet> element is largely obsolete, and modern browsers may not support it. Use modern alternatives for better compatibility.
  • Complex applets: for complex applets, ensure that the fallback content is detailed enough to provide an adequate understanding of the applet’s purpose.
  • Testing across devices: test the fallback content across different devices and browsers to ensure that it provides the necessary information.

Resources