HTML codebase Attribute

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

Definition and Usage

The codebase attribute set a base URL for resources tied to an embedded <applet> or <object> — for example where to find .class files, JARs, or relative classid / data / archive paths.

For new work, put the resource URL in data and set type. Related obsolete attributes: classid, archive, codetype. Document-wide bases use <base> — a different feature.

Deprecated / Obsolete.

Do not use codebase on <object>. The HTML living standard lists it as obsolete — prefer data and type. <applet> itself is obsolete. Learn it to read legacy markup, not to ship it.

HTML Syntax

syntax.html
<applet|object codebase=" URL">

Value is a base URI. Relative resource paths were resolved against it (or against the document base if omitted).

Attribute Values

What authors historically put in codebase:

ValueDescriptionTry it
Directory URLe.g. /applets/ or https://cdn.example/java/Try it
With objectBase for relative classid, data, or archiveTry it
Modern alternativeOmit codebase; use absolute or document-relative data + typeTry it

Live Preview

Toggle a legacy codebase value on a sample <object>. Modern browsers will not run applets/plugins — this demo only shows the attribute.

Legacy study demo. Prefer a full URL in data on <object> in real projects.

Object (fallback shown)

Fallback: the object resource cannot be displayed (expected in modern browsers).

HTML Examples

Legacy snippets for study, plus the modern pattern. Use Try It Yourself for a live editor.

Example 1 — Applet codebase (Legacy)

Old pages pointed codebase at the folder holding the applet’s .class files.

HTML
<applet
  code="Clock.class"
  codebase="/applets/"
  width="200"
  height="200">
  Your browser does not support Java applets.
</applet>
Try It Yourself

How It Works

  1. code named the main class file.
  2. codebase was the directory used to resolve that path.
  3. Fallback text appeared when applets were unavailable.
  4. Study only — never ship <applet> in new sites.

Example 2 — Object codebase (Legacy)

On <object>, codebase resolved relative data / plugin paths.

HTML
<object
  codebase="/plugins/"
  data="player.swf"
  type="application/x-shockwave-flash"
  width="320"
  height="240">
  <p>Plugin content is unavailable.</p>
</object>
Try It Yourself

How It Works

  1. codebase set the base folder for relative resources.
  2. data named the file relative to that base (in legacy models).
  3. type hinted the MIME type for the plugin.
  4. Obsolete today — do not depend on this resolution.

Example 3 — Modern Object Without codebase

What the living standard recommends: put the full resource URL in data.

HTML
<object data="/media/report.pdf" type="application/pdf">
  <p>
    PDF preview is unavailable.
    <a href="/media/report.pdf">Download the report</a>.
  </p>
</object>
Try It Yourself

How It Works

  1. No codebase — obsolete plugin base paths are omitted.
  2. data holds the resource URL directly.
  3. type describes the MIME type.
  4. Fallback keeps the page usable when embed fails.

Edge Cases & Pitfalls

Treat codebase as historical — applets and plugin base paths are gone from the modern web.

obsolete

Not for new HTML

Validators flag codebase on <object>. Firefox removed object codebase support (use data instead).

vs base

Not the same as <base>

<base href> affects the whole document. codebase applied only to one applet/object.

applet

<applet> is obsolete

Do not revive Java applets. Prefer modern embeds or download links with fallback text.

param

Named codebase parameter

Old guidance: if a plugin needed a parameter named codebase, use <param> — still not a reason to ship plugins today.

family

Same fate as classid / archive

classid, archive, and codetype on object are obsolete too — same replacement: data + type.

Browser Support

codebase is a legacy HTML attribute for applet/object resource bases. Engines may still parse it, but applets and plugins no longer run.

✓ Deprecated · Obsolete

codebase

Recognized in old documents for compatibility. Modern browsers do not execute Java applets. Prefer a full URL in data on object.

Legacy Parse only
Google Chrome Ignored for applets
Obsolete*
Mozilla Firefox Removed on object (142+)
Obsolete*
Apple Safari Ignored for applets
Obsolete*
Microsoft Edge Ignored for applets
Obsolete*
Opera Ignored for applets
Obsolete*
Samsung Internet Ignored for applets
Obsolete*
Internet Explorer Legacy applet/plugin era
Legacy*
codebase Obsolete (do not use)

Bottom line: *Parsed for old pages at best — not recommended. Do not build new features on codebase, applets, or plugins.

Key Takeaways

  • Role: base URL for applet/object resource paths.
  • Status: obsolete — keep for reading legacy HTML only.
  • Replace with: full URL in data + type on <object>.
  • ≠ <base> — document base is a different element.

One line: learn codebase for old applet/object markup — ship data and type instead.

Frequently Asked Questions

On applet and object, codebase set a base URL used to resolve relative paths for class files, JARs, classid, data, or archive resources.
Yes. The HTML living standard marks codebase on object as obsolete. The applet element is obsolete too. Prefer object with data and type.
Historically applet and object. Both plugin/applet patterns are obsolete in modern HTML.
No. The base element sets a document-wide default base URL for links and resources. codebase applied only to one applet or object.
Put a full (or document-relative) URL in data on object, and set type as needed. Do not rely on a separate codebase base path.
Yes for reading legacy Java applet and plugin pages. Do not use it in new projects.

Next: codetype

Obsolete content type for the data named by classid.

codetype 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