Applet missing alt
Description
The <applet> element in HTML is used to embed Java applets in a webpage. Although it is considered obsolete and largely replaced by <object> and <embed>, it can still be found in legacy web applications. The alt attribute, or an equivalent text-based alternative, is crucial for accessibility as it provides a textual description of the applet for users who cannot access or interact with it. Missing alt attributes on <applet> elements can lead to significant accessibility issues for users relying on screen readers and other assistive technologies.
Disabilities impacted
- Visual impairments: users with visual impairments who rely on screen readers need alternative text to understand the purpose and function of the applet.
- Cognitive disabilities: users with cognitive disabilities benefit from descriptive text that helps them understand the content and functionality of the applet.
- Technical limitations: users on devices or browsers that do not support Java applets will not be able to access the content without proper alternative text.
Why it matters
Providing alternative text for <applet> elements 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
altattribute:<applet>elements lack thealtattribute or equivalent text-based alternative. - Non-descriptive alternative text: the alternative text provided does not adequately describe the applet’s purpose or functionality.
- Obsolete element usage: using the
<applet>element instead of modern alternatives like<object>or<embed>.
How to fix it
Add descriptive alternative text
Ensure that every <applet> element includes a descriptive alt attribute or equivalent fallback content.
<applet code="ExampleApplet.class" width="300" height="200" alt="This applet demonstrates a simple animation.">
Your browser does not support Java applets. Please use a modern browser or enable Java support.
</applet><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.
<object type="application/x-java-applet" data="ExampleApplet.class" width="300" height="200">
This object demonstrates a simple animation. Please use a modern browser or enable Java support.
</object><applet code="ExampleApplet.class" width="300" height="200"></applet>Provide meaningful alternative text
Ensure that the alternative text or fallback content is descriptive and provides context about the applet’s functionality.
<applet code="WeatherApplet.class" width="300" height="200" alt="This applet displays the current weather conditions.">
This applet displays the current weather conditions. Please use a modern browser or enable Java support to view it.
</applet><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 alternative text is detailed enough to provide an adequate understanding of the applet’s purpose.
- Testing across devices: test the alternative text across different devices and browsers to ensure that it provides the necessary information.