👀 Live Preview
Legacy <object> markup with codetype (modern browsers show fallback content):
object with codetype — Plugin embeds do not run in modern browsers. Fallback text appears instead.

The codetype attribute in HTML is used with the <object> and obsolete <applet> elements to specify the MIME content type of the embedded code when classid is used. It tells the browser what kind of plugin or implementation to expect—for example, a Java applet. This attribute is part of the legacy plugin-embedding model and is not used in modern HTML5 development.
Embed tag.
Code format.
Paired with.
Data MIME.
JS update.
Not inline.
codetype AttributeThe primary purpose of the codetype attribute is to provide metadata about the content type of the code referenced by classid on an embedded element. By declaring a MIME type such as application/java, developers could help user agents determine how to load and run legacy plugin-based content.
codetype is not an attribute of the inline <code> HTML element used to mark up source snippets. It belongs on <object> and <applet> for embedded plugin code.
Add codetype to an <object> or <applet> element with a valid MIME type:
<object classid="clsid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" codetype="application/x-java-applet" width="300" height="200">
<p>Fallback content</p>
</object><object> and obsolete <applet>.classid (and optionally codebase).type, which describes the MIME type of data.The codetype attribute accepts a MIME type value that defines the content type of the embedded code. Common legacy values include:
application/java — Java applet code.application/x-java-applet — Java applet (alternate MIME).application/x-shockwave-flash — Flash plugin content (legacy).<applet code="MyApplet.class" codetype="application/java" width="300" height="200">
Your browser does not support Java applets.
</applet><object classid="clsid:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX" codetype="application/x-java-applet">
<p>Plugin not available.</p>
</object>| Aspect | Details | Modern Alternative |
|---|---|---|
| Elements | <object>, <applet> | <iframe>, <video> |
| Value type | MIME type of embedded code | type on <script> for modules |
| Pairs with | classid, codebase | src + type on media |
vs type | Code MIME (with classid) | type = data MIME (with data) |
| JS access | setAttribute("codetype", mime) | Load modules or media APIs |
| HTML5 status | Obsolete | Avoid in new projects |
| Element | Supported? | Notes |
|---|---|---|
<object> | Yes (legacy) | MIME type of code when classid is used |
<applet> | Yes (obsolete) | Java applets; removed from HTML5 |
<code> | No | Inline code markup; codetype is not valid here |
<script> | No | Use type="module" or default JS |
<embed> | No | Uses type attribute instead |
Object codetype MIME example and dynamic JavaScript setAttribute.
Legacy <object> markup with codetype (modern browsers show fallback content):
object with codetype — Plugin embeds do not run in modern browsers. Fallback text appears instead.
Let’s look at an example of how the codetype attribute is used in an HTML document:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example</title>
</head>
<body>
<p>Embedded Java applet (legacy):</p>
<applet code="MyApplet.class" codetype="application/java" width="300" height="200">
Your browser does not support Java applets.
</applet>
</body>
</html>In this example, the codetype attribute is set to application/java on an <applet> element, indicating that the embedded code is a Java applet. Modern browsers ignore the plugin and display the fallback text instead.
You can dynamically set the codetype attribute using JavaScript when the MIME type must change based on conditions or user interactions:
<object id="dynamicObject" classid="clsid:Example-ID" width="200" height="100">
Plugin not available.
</object>
<script>
document.getElementById("dynamicObject")
.setAttribute("codetype", "application/x-java-applet");
</script>In this script, the codetype attribute is dynamically set to application/x-java-applet on the object element with id dynamicObject using setAttribute.
<object> or <applet> when plugins fail.Add a MIME type on <object> or <applet> alongside classid or code.
The user agent uses the MIME type to identify the expected plugin or code format.
Legacy browsers attempted to load the implementation from classid / codebase.
Modern browsers skip plugins and show fallback content instead.
The codetype attribute is obsolete. It was used with Java applets and other browser plugins that have been removed from all major browsers.
Use <iframe>, <video>, ES modules, or Web APIs instead of plugin embeds.
Bottom line: Learn codetype for legacy maintenance only. Do not use plugin embeds in new web applications.
codetype when reading legacy markupcodetype with classid on <object> as intendedcodetype from type and from the <code> elementcodetype on the inline <code> elementtype on the same objectcodetype attribute to declare the correct MIME type for embedded code referenced by classid.codetype alongside related attributes like classid and codebase.The codetype attribute was a useful tool for specifying the content type of embedded code on <object> and <applet> elements in legacy HTML documents.
By understanding how this attribute works—and how it differs from the inline <code> element—developers can read and maintain older plugin-based pages. For new projects, use secure, widely supported HTML5 technologies instead.
codetypeBookmark these when reading legacy HTML.
Code format.
PurposeEmbed tag.
ElementPaired with.
RelatedData MIME.
CompareInline tag.
Warning<object> or <applet> when classid is used.<code> element does not support a codetype attribute. That was a common misconception in older tutorials.codetype is the MIME type of code (with classid). type is the MIME type of data (with data).<object> and obsolete <applet>. It is not a global attribute.element.setAttribute("codetype", "application/java") on the object or applet element.Explore the obsolete codetype attribute on <object> and <applet>, and learn why it is not used on the inline <code> element.
5 people found this page helpful