HTML codetype Attribute

Beginner
5 min read
Updated: Oct 2026
3 examples
Live preview

Definition and Usage

The codetype attribute on <object> gave the MIME content type of the code pointed to by classid (plugin / ActiveX / applet era). It is not an attribute of the inline <code> element.

For new pages, use data plus type on <object>, or native embeds such as <iframe>, <embed>, and media elements.

Obsolete.

Do not use codetype in new HTML. The Living Standard lists it with classid, code, codebase, and archive on <object> — learn it to read legacy markup only.

HTML Syntax

syntax.html
<object classid=" URI" codetype="MIME-type"> … </object>

MIME-type is a media type string (e.g. application/java). Always include fallback content inside <object>.

Attribute Values

Value is a single MIME type for the classid implementation. Common legacy examples:

ValueDescriptionTry it
application/javaJava applet / Java code MIME (legacy)Try it
application/x-java-appletAlternate Java applet MIME used with classidTry it
application/x-shockwave-flashLegacy Flash plugin MIME (no longer used)Try it
Any valid MIME typeMust describe the classid code — not the data resourceTry it
Modern replacementUse data + type instead of classid + codetypeTry it

Live Preview

Change codetype on a demo <object>. Modern browsers ignore plugin loading and show the fallback text.

Study-only markup. Plugins do not run; fallback content is what users see.

object demo
Fallback: plugin not available in this browser.

codetype="application/java"

HTML Examples

Short study snippets. Use Try It Yourself for a live editor. Prefer example 3 for new work.

Example 1 — Legacy object with classid

Historical pattern: classid names the implementation; codetype states its MIME type.

HTML
<object
  classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
  codetype="application/x-java-applet"
  width="300"
  height="200">
  Java plugin is not available. Use a modern browser and native HTML instead.
</object>
Try It Yourself

How It Works

  1. classid pointed at a COM/plugin implementation (often a clsid: URI).
  2. codetype told the browser the MIME type of that code (here, a Java applet).
  3. Fallback content inside <object> shows when the plugin cannot run.
  4. Obsolete today. Keep this only to understand old pages — do not ship it.

Example 2 — codetype vs type

codetype goes with classid. type goes with data. They answer different questions.

HTML
<!-- Legacy: MIME of the classid code -->
<object
  classid="clsid:Example-ID"
  codetype="application/x-shockwave-flash"
  width="200"
  height="100">
  Flash is not supported.
</object>

<!-- Modern idea: MIME of the data resource -->
<object
  data="sample.pdf"
  type="application/pdf"
  width="200"
  height="100">
  <a href="sample.pdf">Download the PDF</a>
</object>
Try It Yourself

How It Works

  1. codetype + classid = “what kind of code is this plugin?”
  2. type + data = “what kind of resource is at this URL?”
  3. Do not mix roles. Putting a data MIME on codetype does not modernize the tag.
  4. Study both so legacy docs and new <object> usage stay clear.

Example 3 — Modern replacement (data + type)

What the HTML Standard recommends instead of classid / codetype.

HTML
<object
  data="/media/demo.mp4"
  type="video/mp4"
  width="320"
  height="180">
  <p>
    Your browser cannot display this video.
    <a href="/media/demo.mp4">Download the MP4</a>.
  </p>
</object>
Try It Yourself

How It Works

  1. data is the resource URL (required in practice with type, or either alone per MDN).
  2. type is the MIME type of that resource — the modern stand-in for what codetype tried to do for plugins.
  3. Fallback stays inside <object> for accessibility when the resource fails.
  4. Prefer native tags when they fit: <video>, <iframe>, <img>, etc.

Edge Cases & Pitfalls

Most mistakes mix up plugin MIME attributes with modern type, or confuse codetype with <code>.

obsolete

Not for new projects

Validators and the HTML Standard flag codetype. Remove it when updating legacy templates.

naming

Not the <code> element

codetype never styled or typed inline code. Use <code> for snippets; use type on media/scripts when needed.

pairing

Goes with classid, not data

It described the content type of data specified by classid. For a URL resource, use type with data.

param

Need a “codetype” parameter?

The Standard says: if you need a parameter named codetype, use a <param> child — not the obsolete attribute.

plugins

No plugin runtime anymore

Flash, Java applets, and ActiveX are gone from mainstream browsers. Expect fallback content only.

Browser Support

codetype is an obsolete HTML attribute on <object>. Engines may still expose it in the DOM for compatibility, but plugin behavior is gone.

✓ Obsolete · Do not use

codetype

Recognized historically with classid for plugins. Modern Chrome, Firefox, Safari, and Edge do not run those plugins — use data and type (or native embeds) instead.

Legacy Compatibility only
Google Chrome Attribute may exist; no plugins
Obsolete*
Mozilla Firefox Attribute may exist; no plugins
Obsolete*
Apple Safari Attribute may exist; no plugins
Obsolete*
Microsoft Edge Attribute may exist; no plugins
Obsolete*
Opera Attribute may exist; no plugins
Obsolete*
Samsung Internet Attribute may exist; no plugins
Obsolete*
Internet Explorer Legacy ActiveX / plugins era
Legacy*
codetype Obsolete (ignored for plugins)

Bottom line: *Do not use in new pages. Migrate to data + type, iframe, embed, or media elements.

Key Takeaways

  • Role: MIME type of classid code on legacy <object>.
  • Status: obsolete — study for old markup only.
  • vs type: codetype → classid code; type → data resource.
  • Replace with: data + type, or native embed elements.

One line: codetype was plugin MIME for classid — ship data + type instead.

Frequently Asked Questions

On object (and historically applet), codetype gave the MIME content type of the code referenced by classid, so the browser could pick a plugin. It does not apply to the inline code element.
Obsolete. The HTML Living Standard lists codetype on object as obsolete. Authors must not use it. Prefer data and type on object, or iframe, embed, video, and other native embeds.
codetype described the MIME type of classid code. type describes the MIME type of the resource in data. Modern pages use type with data, not codetype with classid.
Primarily object. Older tutorials also show it on applet. It is not valid on code, script, or embed.
No. NPAPI plugins, Java applets, and ActiveX are gone from mainstream browsers. You will usually see only the object’s fallback content.
Use object with data and type, or iframe, embed, video, audio, or img depending on the resource. If you need a parameter literally named codetype, use a param child element.

Next: color

Deprecated presentational color on font and hr — and what CSS replaces it.

color tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

8 people found this page helpful